-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A Trust DNS based Recursor #1710
Conversation
This now wired up end to end, using this branch to checkout, and run from the root of the project directory, the recursor can be tested with:
And then I used the resolve command to test with:
The first call timed out as the recursion took longer than the timeout in the resolve command, but the second worked as it was cached at that point:
|
7a2eee9
to
9c99458
Compare
Sorry for the delay in landing this. I want to try and build some tests to help verify this code before we land it. Those are taking me a bit of time to get in place. |
@djc, I'd like to land this so that we can do a release. I've marked it as experimental since we have very little test coverage on the new recursor crate at the moment. I think the most controversial thing here is that we're exposing a few more things from the resolver to reuse for this, but those are very useful here. Once this is passing I think it's ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've skimmed this and it mostly seems reasonable.
crates/recursor/src/recursor.rs
Outdated
use crate::{recursor_pool::RecursorPool, Error, ErrorKind}; | ||
|
||
/// Set of nameservers by the zone name | ||
type NameServerCache = LruCache<Name, RecursorPool>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: I've kind of soured on type aliases; in my experience they make the code harder to understand (because of more opaque types) at not much benefit (no isolation of the inner type).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure on this one. I agree in principle, the issue is that the type becomes a bit unwieldy with all the generics, and that can cause a readability problem as well.
@@ -133,12 +132,10 @@ pub struct DnsResponse(Message); | |||
// TODO: when `impl Trait` lands in stable, remove this, and expose FlatMap over answers, et al. | |||
impl DnsResponse { | |||
/// Retrieves the SOA from the response. This will only exist if it was an authoritative response. | |||
pub fn soa(&self) -> Option<SOA> { | |||
pub fn soa(&self) -> Option<&Record> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this? I can see that it's nice to avoid the clone, but it seems like returning &SOA
would make life easier for downstream users? What do we need out of the Record
in callers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I needed all the fields of Record. I was thinking about introducing a new TypedRecord
... not sure if nows a good time for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djc, I started working on resolving the issue here. I think it's going to take a new type, that I'll plan to call TypedRecord
. This will take the form of TypedRecord<R: RecordData>
which will also introduce a new trait RecordData
that all the RData
types will implement. To facilitate the reference form, I think we might also need a TypedRecordRef<'_, R>
, which would carry a reference to the interior RecordData and Name.
So I'd like to merge this as is, and then follow up with a PR to introduce that type, which may be a bigger refactor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Is the idea that we're getting rid of the RData
enum in favor of a trait-based (that is, open) API, or will we keep both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd keep both? We need something generic in the Record, and I like the known sizes of all the types. Otherwise we'd need to box the types I think... the enum is generic across them all, so I was thinking TypedRecord<RData>
would be the generic version. You can convince me otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is the best place for this discussion but would like to understand what problem TypedRecord
and/or TypedRecordRef
are supposed to solve.
b97e9a7
to
53faeb3
Compare
This is pretty rough right now, probably a lot of work to do, but it does work for some basic queries, for example:
cargo run --all-features --bin recurse -- --debug -n 192.5.5.241:53 -t A www.example.com.
need some cleanup on output, but this is the current result:
I don't think this is ready for review yet, lots to cleanup.
fixes: #1440