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
(wip) use resolv_conf to parse resolv.conf files #305
Conversation
resolver/Cargo.toml
Outdated
[dependencies] | ||
# resolv-conf = { git = "https://github.com/tailhook/resolv-conf" } | ||
resolv-conf = { path = "../../resolv-conf/" } |
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.
that won't compile due to this. I'll uncomment the line above one when tailhook/resolv-conf#5 is merged.
8d73fbb
to
dbbf126
Compare
I agree. Domain and Search are generally treated the same, so I understand why they are combined in the library. Their usage is here (it's a stack, so the last thing pushed will be the first lookup attempted): https://github.com/bluejekyll/trust-dns/blob/master/resolver/src/resolver_future.rs#L186-L208 As you can see, they are basically treated the same way in the resolver, so it's not horrible that All the other changes look good. |
Codecov Report
@@ Coverage Diff @@
## master #305 +/- ##
==========================================
- Coverage 86.8% 86.69% -0.12%
==========================================
Files 114 113 -1
Lines 11794 11679 -115
==========================================
- Hits 10238 10125 -113
+ Misses 1556 1554 -2
Continue to review full report at Codecov.
|
I'm not sure about the logic of putting the domain at the beginning of the search list. By the way, I see that by default,
|
Sorry, by mutually exclusive you mean you can't have both in the resolv.conf file? If that's accurate we can change it. I may have misunderstood the specs here.
I agree that we should "try", but if it's not successful it makes sense to me to default to '.', as there aren't a lot of other options at that point... |
We can have both but the last occurence is supposed to win. Quoting
I think this is a change to do
There is one more option in case neither
|
To sum up I think that this is how we should build the search list:
EDIT: at least for Linux (and BSD probably). I'm not sure if it's the same for Mac. |
I want to clarify some things in your proposed algorithm.
I'd personally like to see domain always included, regardless of search. a)
This feels more deterministic to me. Otherwise we end up with some awkward things where some are used or not used in different situations. I do like using adding Thoughts? edit: I keep reading this and it doesn't make sense to me why they both exist if only one can be used. for reference if others don't have the man page: http://man7.org/linux/man-pages/man5/resolv.conf.5.html If we decide to only support |
Yes sorry, I forgot to mention the fqdn variant. It's always tried first based on the
Yes, my only two sources are the "DNS & Bind" book and the resolv.conf man page. And I agree that this algorithm makes Edit: Sorry I realize I missed this sentence in your reply:
That's basically what I'm saying too, so I think we're on the same page! |
this change is awesome. |
I think we are on the same page at this point. Thanks for working on this! |
Some resolvers need to distinguish the domain from the search list (see for example hickory-dns/hickory-dns#305 (comment)) to build a list of suffixes.
resolv_conf[0] is a parser for resolv.conf files that depends on a single crate. Using it instead of the LALRPOP parser makes builds faster, and adds better support for comments. [0] https://github.com/tailhook/resolv-conf
Add logic to try to determin the domain from: - the LOCALDOMAIN environment variable - the hostname - the config file (/etc/resolv.conf) This adds a dependency on the "hostname" crate[0] [0] https://docs.rs/hostname/0.1.3/hostname/
dbbf126
to
b97607b
Compare
I pushed new commits that make Apart from this I see two things missing I'd like to address in this PR:
|
https://github.com/bluejekyll/trust-dns/blob/master/resolver/src/resolver_future.rs#L176-L180 |
oh nice, I didn't realize! |
Yeah, it's not efficient, but I think this list will always be small in general, so the search on the Vec seems fine to me... |
I'll wait for tailhook/resolv-conf#6 to continue working on this. |
tailhook/resolv-conf#6 is already merged. |
@cssivision I'm travelling right now. I'll try to finish this up tomorrow. |
ping, @little-dude do you want to finish this one up? If you don't have time, I can finish it off for you... |
how about this pr? @bluejekyll |
} | ||
|
||
// #[test] | ||
// fn test_ip_addr() { |
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.
The rest of these tests seem to be all commented out. Do you think we should just remove them?
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 open to this.
I think if the tests that are all commented out are now irrelevant, let’s just remove them. Otherwise, the PR looks good to me, and I’m ready to merge in once it’s updated and tests are passing. Thanks for picking this back up! Edit: looks like a misidentified you as the owner of this @cssivision. I think it's worth getting this in for the faster builds it will produce. I'll see about trying to do it this weekend if @little-dude doesn't have time. |
I cut a new pr including this change, #335 |
this was merged in with #335 |
This is still work in progress but I'm opening early to have feedback about whether this is the right direction.
Here is what I did:
Eq
is convenient to have for tests, andCopy
is convenient forNameServerConfig
)Note that for the moment, this depends on tailhook/resolv-conf#5
Also, for the moment
resolv-conf
does not make a distinction betweendomain
andsearch
: https://github.com/tailhook/resolv-conf/blob/d7ab0ce0a80f6433dbb6ba32468ad3e6b5d272c2/src/grammar.rs#L141-L149I think this is an issue.