mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #350] How to set client-subnet for query? #457
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#457
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aggrolite on GitHub (Feb 26, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/350
How can I set client-subnet for a DNS query? Any way to do that with
SyncClient.query()?I'd like to mimic:
dig github.com +subnet=1.2.3.4/32@bluejekyll commented on GitHub (Feb 26, 2018):
That’s currently not supported. I haven’t had a need for that myself, but it doesn’t look like it should be easy to add. It looks like that’s an EDNS option. EDNS is supported by TRust-DNS, so it would be a matter of adding the variant the the EDNS options. If this is the Client, then that would be it. For the Resolver there would be a bigger discussion around how to support that in the API.
@aggrolite commented on GitHub (Feb 26, 2018):
Okay, thanks. Right now I'd be looking at using client-subnet with Client.
For adding the feature to Client, what approach would make the most sense (I'm new to Rust)?
From my perspective, it makes sense to write the following:
In which case I'm guessing the function would be added to
SyncClient, or whatever type it's based on.@bluejekyll commented on GitHub (Feb 26, 2018):
That’s one option. There’s another which would be to associate edns which each query or other message, rather than exposing a new api on the client. There are pros and cons to each... not sure which way I’d leaning at the moment.
@bluejekyll commented on GitHub (Feb 26, 2018):
Let’s see what your method ends up looking like. It might be that we have different options based on different contexts, and there’s no single correct way since EDNS is such a grab bag of options.
@LEXUGE commented on GitHub (Dec 14, 2020):
How is it going here?
@leshow commented on GitHub (Mar 29, 2021):
I stumbled on this issue because I am looking for similar functionality. I'd like to see this taken more generally so we can use it for any opt record. I'm happy to implement if you're open to accepting a PR to
trust-dns-client?As for what to do, right now we have
queryhttps://docs.rs/trust-dns-client/0.20.1/trust_dns_client/client/trait.Client.html#method.queryFor a dead-simple solution that would provide the functionality, we could add another method that accepted an
Edns?fn query_edns(&self, name: Name, query_class: DNSClass, query_type: RecordType, edns: Edns) -> ClientResult<DnsResponse>&EdnsorEdns?In any case, that would require making a new
Ednsper query or at least cloning/moving one. The alternative isset_ednsand have it re-use the same edns for every query but I think some kind ofquery_ednsmethod makes more sense.Let me know what you think @bluejekyll
edit: another option:
fn send_msg(msg: Message) -> ClientResult<DnsResponse>or something like that?@bluejekyll commented on GitHub (Mar 29, 2021):
@leshow, I wonder if we want to create a new
QueryBuilderthat would allow for adding all of these options in a more elegant manner? Perhaps rather than Exposing the complexities of Edns directly, theQueryBuildercould have aadd_subnetmethod that would populate the Edns fields for a caller?Folks can always drop back to the
send_msgfunction for this or more advanced usage.edit: looking at the interfaces today, maybe a
DnsRequestBuilderis the correct thing? And that would just hold a DnsRequest (Message) while it's being built up and then send could be used? https://docs.rs/trust-dns-proto/0.20.1/trust_dns_proto/xfer/dns_handle/trait.DnsHandle.html#tymethod.send@djc commented on GitHub (Mar 29, 2021):
Yeah, builders are the common pattern for stuff like this. I think that could make a lot of sense.
@leshow commented on GitHub (Mar 29, 2021):
As it happens I do have a half finished branch with *builder pattern types after our last discussion, but I was sort of picturing that to be independent of this. Happy to do the
send_msgvariant and land builder pattern stuff later though?I wrote some of this in the PR, but since
DnsRequestBuilderhas pub fields I thought it'd be a breaking change to replaceuse_ednswith likeedns: Option<Edns>@bluejekyll commented on GitHub (Mar 29, 2021):
DnsRequestis basically just a wrapper on Message... for Client this is probably the correct thing. I noticed you adding a similar method to the Resolver in your PR, using that one, I wonder if there it's more obvious as aLookupBuilder, and probably should be a simpler abstraction then the full power of offering up Message?@leshow commented on GitHub (Mar 29, 2021):
Woops I meant
DnsRequestOptionsin that last message. What sort of things would you expose in a hypotheticalLookupBuilderthat would make it different from aMessageBuilderor something like that?edit: I see you referred to
send, but AFAIK that doesn't exist forSyncClient, so there is no way to send an arbitraryMessagewith the sync interface@bluejekyll commented on GitHub (Mar 29, 2021):
One reason I don't want to expose
MessageBuilderto users of the Resolver lookup interfaces is that there are a lot of things that are transformed in messages when they are being sent. Simple things like themessage_idwhich changes on each request, and the resolver will make many requests potentially to fulfill a lookup (likeCNAMEchain resolution). Additionally, there are things like per DNS resolver endpoint EDNS configs, where we may want/need to push EDNS options on initial connection in TCP, but not on every request.So it's definitely a subset of the
Messagedata. I'm thinking ofLookupBuilderas an extension the lookup options today, so it would beQuery+ some EDNS options data (like subnet), but not the entire EDNS object, because that might have to be generated on a per request basis.Does that make sense?
Example:
@leshow commented on GitHub (Mar 29, 2021):
That seems reasonable, I have a few additional questions though 😅
What type does
buildproduce in your above code example?DnsRequest?Message? some newLookupOptionstype?We'll have to also add a method to the
Clienttrait for this to be usable from both the sync/async clients too I think, since there is nosendfor sync (that I can see)?@bluejekyll commented on GitHub (Mar 29, 2021):
I think we should discuss the Resolver and Client changes separately. The Resolver generally hides a lot of details from users of the API, and I can't decide if subnet is a per lookup option, or possibly a general configuration option that should be applied to an entire Resolver instance?
Any chance you could hop on discord to discuss? https://discord.gg/89nxE4n