mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #370] Passing TCP or UDP client as an argument #170
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#170
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 @msehnout on GitHub (Apr 3, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/370
How can I specify a function, that takes either UDP or TCP client? I have a
SyncClientwithUdpClientConnectionwritten like this:but I would like to it accept either
UdpClientConnectionorTcpClientConnection. I tried to use Client as a trait bound, but I failed to compile my code. Can you help me with this?@msehnout commented on GitHub (Apr 3, 2018):
edit: I found your blog post: http://bluejekyll.github.io/blog/rust/2017/08/06/type-parameters.html and managed to do it, but it was tough :-)
@bluejekyll commented on GitHub (Apr 3, 2018):
Glad you worked through it! Yes these interfaces need to be simplified. The traits are confusing at the moment, and their type parameters as well.
Out of curiosity, did you look at the Resolver which does this implicitly?
@msehnout commented on GitHub (Apr 4, 2018):
I looked into the code of the Resolver for inspiration :-) , but I need direct control over the underlying protocol. I'd like to implement some test as defined in RFC 8027
@bluejekyll commented on GitHub (Apr 4, 2018):
Oh, that would be a cool tool. Yeah, that's a good use for the client. At some point it would be great to clean the library up and make some of these interfaces simpler, or at least more straight-forward idiomatic Rust. Let me know if you run into any issues.
@msehnout commented on GitHub (Apr 7, 2018):
I tried to implement the third test, EDNS0 support. I had to create the DNS message by hand and then send it manually. It took me some time to find out where to put the message to get response back. Eventually I copied&pasted some code from the resolver and client crates a managed to implement the test.
One issue I had, is that the DnsHandle trait is available only from the trust-dns-proto crate, which from my understanding is not supposed to be used directly.
Import: https://github.com/msehnout/dns-roadblock-tests/blob/master/src/main.rs#L19
Usage: https://github.com/msehnout/dns-roadblock-tests/blob/master/src/main.rs#L100
The second thing I don't understand is this part:
https://github.com/msehnout/dns-roadblock-tests/blob/master/src/main.rs#L98
What is the purpose of creating stream and stream_handle? And why do I pass the handle to the ClientFuture, when eventually I pass the response_future to the reactor?
@bluejekyll commented on GitHub (Apr 7, 2018):
We can clean up the
new_stream()interface so that this is a little easier for external implementations like this. A single combined type as the result would do that. I haven't spent much time cleaning things like this up. The reason there are two, is that DNS supports out of order message sending and delivery. So we can't have a simple high-level interface over the stream for sending/receiving. If you want to file an issue for cleaning up that interface please do. Thestreamis the i/o processor, whereas thehandleis the thing which you use to send messages to thestream. This shouldn't be something your library cares about, so simplifying that to a single type makes a lot of sense.If
DnsHandleneeds to be public to support your use-case, I'm fine with us doing that. I was generally trying to steer people away from some of this complexity. Also, for anything where you needed to directly pull in trust_dns_proto, we should reexport that in thetrust-dnscrate.@msehnout commented on GitHub (Apr 12, 2018):
Eventually I switched to using
DnsHandleas an argument instead of theSyncClient. I would also like to ask about the message composition together with Edns, am I using it correctly here?https://github.com/msehnout/dns-roadblock-tests/blob/master/src/main.rs#L52
Because when I run those tests against Google public DNS, Cloudflare DNS and my local Unbound resolver, the local resolver always return with "Refused"
@bluejekyll commented on GitHub (Apr 12, 2018):
That construction looks ok. I think the issue is the
EdnsCode::Zerousage, we may want to disallow use of that parameter. Here's a list of the valid edns codes: https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-11, Zero is reserved, and as far as I know not used for anything.The upstream resolvers may be rejecting the DNS message b/c of that.
@bluejekyll commented on GitHub (Apr 13, 2018):
Reading you're question again. I wonder if there's some confusion here.
EDNS(0)is the name of the current RFC onEDNS, it does not mean anEDNSwith an associatedEdnsOptionof the codeEdnsCode::Zero, it is actually referring to theedns.version(), inEDNS(0), where the version is0,0specifying that the library is in full compliance with the RFC.https://tools.ietf.org/html/rfc6891
@msehnout commented on GitHub (Apr 13, 2018):
Yes, it seems, that I did not understand the test definition:
https://tools.ietf.org/html/rfc8027#section-3.1.3
So I guess, this line:
should by replaced with this:
Resulting in this message: