Comments (11)
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:
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.
Thanks very much for your UDP example code. It's working for me now.
Great!
from hickory-dns.
What are you trying to do? For most use cases, the -resolver crate might be more appropriate than the -client crate.
from hickory-dns.
What are you trying to do? For most use cases, the -resolver crate might be more appropriate than the -client crate.
I'm trying to use AsyncClient in axum http handler to delete/add dns records from/to bind name server?
from hickory-dns.
Okay, you'll actually need the client for that. What do you mean by UdpStream
?
from hickory-dns.
Okay, you'll actually need the client for that. What do you mean by
UdpStream
?
For tcp, the below code is working,I‘d like to know how to replace tcp with udp
let addr = "127.0.0.1:53".parse().unwrap();
let (stream, sender) = TcpClientStream::<AsyncIoTokioAsStd<TokioTcpStream>>::new(addr);
let client = AsyncClient::new(stream, sender, None);
let (client, bg) = client.await.unwrap();
tokio::spawn(bg);
from hickory-dns.
Have you looked at the documented examples, here? https://docs.rs/trust-dns-client/latest/trust_dns_client/#setup-a-connection
from hickory-dns.
Have you looked at the documented examples, here? https://docs.rs/trust-dns-client/latest/trust_dns_client/#setup-a-connection
Yes,the AsyncClient example is for tcp stream only
from hickory-dns.
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.
from hickory-dns.
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.
For UDP, how can I get sender: BufDnsStreamHandle for the second param of asyncclient::new()
pub fn UdpClientStream::new(name_server: SocketAddr) -> UdpClientConnect<S, NoopMessageFinalizer>
pub fn TcpClientStream::new(name_server: SocketAddr) -> (TcpClientConnect<S>, BufDnsStreamHandle)
pub async fn AsyncClient::new<F, S>(stream: F, stream_handle: BufDnsStreamHandle, signer: Option<Arc<Signer>>)
from hickory-dns.
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:
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.
from hickory-dns.
Hi,
I have a follow-up question, how can I use AsyncClient
with a UdpStream
and SigSigner
? The following doesn't work because UdpClientStream
requires the NoopMessageFinalizer
:
let signer = SigSigner::sig0(sig0key, key, Name::from_str("update.example.com.").unwrap());
let address = "8.8.8.8:53".parse().unwrap();
let conn = UdpClientStream::<UdpSocket>::with_timeout_and_signer(
address,
Duration::from_secs(5),
Some(Arc::new(signer)),
);
And the following doesn't work either as DnsClientStream
is not implemented for UdpClientStream
:
let conn = UdpClientStream::<UdpSocket>::new(address);
let (client, bg) = AsyncClient::new(conn, BufDnsStreamHandle::new(address), signer)
.await
.unwrap();
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 ring
when OpenSSL is disabled.
Edit: Just found out how to do it. In case someone is looking for an example on how to use SigSigner
on an async UDP connection, here it is:
let conn = UdpClientConnection::new(address)
.unwrap()
.new_stream(Some(Arc::new(Signer::from(signer))));
let (client, bg) = AsyncClient::connect(conn).await.unwrap();
from hickory-dns.
Related Issues (20)
- `hickory-dns` responds to `dig A doesnotexist.fqdn.com.` with NOERROR instead of with NXDOMAIN HOT 6
- `hickory-dns` resolver does not honor the DO bit in client's queries HOT 2
- [RFC] DNSSEC validation: configuration syntax HOT 10
- [RFC] re-structure `named.toml` syntax to reject invalid configurations HOT 3
- TCP fallback is not always used and forcing it is not ergonomic HOT 3
- 0.25 Release HOT 10
- Static build support (openssl + cross-compile) HOT 6
- `DnssecDnsHandle` does not appear to validate RRSIG's signature {inception,expiration} fields HOT 1
- malformed query can cause assertion failure at encoder.rs:234 HOT 1
- should `proto::rr::resource::Record.rdata` really be an `Option`? HOT 6
- `just clippy` does not catch warnings produced by `just dnssec-openssl` HOT 5
- DNS Resolver rotate feature HOT 5
- [Featture] Expose Path Parameter for DoH Client HOT 1
- Allow passing in a custom client UDP socket to send data from HOT 5
- `just no-default-features` fails with an ICE using latest nightly HOT 1
- Default dns timeout of 5 seconds is excessive (causes 40s of time being wasted in mongodb) HOT 5
- hickory-resolver retries NXDOMAINs over TCP if using `try_tcp_on_error` HOT 4
- tag/publish a 0.25 pre-release? HOT 1
- What is the reason for NextRandomUdpSocket? HOT 6
- add DNSSEC validation to `Recursor` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hickory-dns.