mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-24 18:55:55 +03:00
[GH-ISSUE #1100] DNS lookup on custom TCP-like stream? #606
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#606
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 @Mygod on GitHub (May 10, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1100
What is the best way to implement DNS lookup on a custom struct that implements
DnsStreamHandle, e.g. wrapping atokio::net::UnixStreamor a proxy TCP stream, so that it can use all the features in this library, e.g. connection reuse?@bluejekyll commented on GitHub (May 10, 2020):
Which part of the library do you mean? The
trust-dns-resolverlibrary already does this, you can just configure the resolver to only use TCP/TLS/HTTPS, and then it would reuse those connections.If you want to get a raw packet, then
trust-dns-clientis probably what you want, though that won't do anything like CNAME resolution, and you'll need to interpret the DNS Message to extract the data types you want.@Mygod commented on GitHub (May 10, 2020):
Ah there is a client library. I missed that.
Though my use case is slightly different.
TcpClientStreamis still restrictive for us, in particular, theasync fnintrust_dns_proto::tcp::Connectonly takesSocketAddr, however, we want the stream initialization to be done via some other process (UnixStreamor proxy set up). We currently have re-implemented a lot of stuff but it would be great if we can use the connection pooling in this library...@bluejekyll commented on GitHub (May 10, 2020):
I think I understand what you want, though I don't think the library is necessarily in the best state to make that easy. I think you could implement your own version of
TcpClientStreamand then you could use the https://docs.rs/trust-dns-client/0.19.5/trust_dns_client/client/struct.AsyncClient.html#method.connect for using it.You may want to explore using https://docs.rs/trust-dns-proto/0.19.5/trust_dns_proto/xfer/dns_multiplexer/struct.DnsMultiplexer.html for multiplexing over a single TCP stream. Then there is the https://docs.rs/trust-dns-proto/0.19.5/trust_dns_proto/xfer/struct.DnsExchange.html which can be used to wrap a multiplexed stream and properly dispatch and convert responses back to the requesting task. While the Client itself is not used in the trust-dns-resolver, the exchange and multiplexer are.
@Mygod commented on GitHub (May 10, 2020):
Thanks! By the way does this library support connection pooling?
@bluejekyll commented on GitHub (May 11, 2020):
The Client doesn’t, but the Resolver does.
@Mygod commented on GitHub (May 11, 2020):
Ah I have given up trying to integrate the client library. For now I think I will keep implementing our own client/server code along with
trust-dns-proto...I'd be keen to go back if it gets easier for me to integrate the client library. 🤣
@bluejekyll commented on GitHub (May 11, 2020):
Btw, it is possible in the Resolver to use custom TCP streams, by way of implementing a custom
Runtimeand orConnectionProvider@bluejekyll commented on GitHub (May 11, 2020):
Also, if you have notes on what was complicated, and what you would like to see changed in the Client, we should capture those, and maybe someone will have some energy to work on them.
@Mygod commented on GitHub (May 12, 2020):
Yes I made a preliminary attempt here. How do I integrate it with trust-dns so that I can use the connection pool etc?
@Jason5Lee commented on GitHub (Sep 1, 2020):
I have a similar requirement where I want to resolve DNS through socks5 proxy.
@kmod-midori commented on GitHub (Nov 17, 2020):
Most libraries dealing with streams accept something like
where S: AsyncRead + AsyncWrite + Unpin, making them more flexible. I wonder if we could have something similar, like atrait StreamFactory?