mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #2058] How can AsyncClient be used with UdpStream? #865
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#865
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 @qjmiao on GitHub (Oct 12, 2023).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2058
Are there any examples on AsyncClient being used with UdpStream?
@djc commented on GitHub (Oct 12, 2023):
What are you trying to do? For most use cases, the -resolver crate might be more appropriate than the -client crate.
@qjmiao commented on GitHub (Oct 12, 2023):
I'm trying to use AsyncClient in axum http handler to delete/add dns records from/to bind name server?
@djc commented on GitHub (Oct 12, 2023):
Okay, you'll actually need the client for that. What do you mean by
UdpStream?@qjmiao commented on GitHub (Oct 12, 2023):
For tcp, the below code is working,I‘d like to know how to replace tcp with udp
@bluejekyll commented on GitHub (Oct 12, 2023):
Have you looked at the documented examples, here? https://docs.rs/trust-dns-client/latest/trust_dns_client/#setup-a-connection
@qjmiao commented on GitHub (Oct 12, 2023):
Yes,the AsyncClient example is for tcp stream only
@bluejekyll commented on GitHub (Oct 12, 2023):
This is the same interface as the TCP variant, https://docs.rs/trust-dns-client/latest/trust_dns_client/udp/struct.UdpClientStream.html#method.new
it should work the same was as that tcp example in an async context.
@qjmiao commented on GitHub (Oct 12, 2023):
@bluejekyll commented on GitHub (Oct 12, 2023):
Ah, I'm sorry. We should add an example of this. I even gave you bad advice on the interface, here's a good example for you:
github.com/bluejekyll/trust-dns@c9cc5c9dd0/util/src/bin/dns.rs (L251-L253)edit: for some additional context on why TCP and UDP have different interfaces, UDP can do more operations in the foreground thread because the Socket is shared for all operations. TCP on the other hand needs to establish a new socket and connection for each request, and that happens in a background task, which is why it has a slightly more complicated interface.
@qjmiao commented on GitHub (Oct 12, 2023):
Thanks very much for your UDP example code. It's working for me now.
Great!
@mdecimus commented on GitHub (Feb 15, 2024):
Hi,
I have a follow-up question, how can I use
AsyncClientwith aUdpStreamandSigSigner? The following doesn't work becauseUdpClientStreamrequires theNoopMessageFinalizer:And the following doesn't work either as
DnsClientStreamis not implemented forUdpClientStream:And one final slightly related question, do you have plans to support Sig0 RSA signing without requiring OpenSSL? I want to avoid this dependency and currently only ECDSA and ED25519 are available through
ringwhen OpenSSL is disabled.Edit: Just found out how to do it. In case someone is looking for an example on how to use
SigSigneron an async UDP connection, here it is: