mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-24 18:55:55 +03:00
[GH-ISSUE #624] Expose send on the SyncClient #255
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#255
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 @mattias-p on GitHub (Nov 21, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/624
I need to send queries with the RD flag disables. I started out with the SyncClient hello world example and just inlined my way towards the Message. However I can't inline client::ClientHandle::query because client::ClientResponse's data member is private and there's no constructor.
A public constructor for ClientResponse would solve my problem. Making the data member public would also work, but from my limited understanding it makes more sense to keep ClientResponse opaque.
@bluejekyll commented on GitHub (Nov 22, 2018):
I don't think this is actually what you want. Based on your description, you want to have more control over how the
DnsRequestis constructed, or even directly send your own message. This method exists, but currently only exists on theClientFuture, the async version of theSyncClient. It's theDnsHandle::sendmethod implemented on BasicClientHandle (returned during construction of the ClientFuture). It should be fairly straightforward to expose this on theSyncClientin a similar way as the other methods,queryfor example, are exposed from theClienttrait implementation.Would you want to make this change to implement
Client::sendas a delegate to the underlyingsendmethod? This should look a lot like the other default implementations on theClienttrait.Another more extensive change we could make would be to create a new pre send hook, where a message could be inspected before send, and allow you to override different portions of the
Messageprior to it being sent. This might be better in the long run.@mattias-p commented on GitHub (Nov 22, 2018):
Thank you so much for your excellent response! Your explanation validates my general approach and it helped me realize where I went wrong.
I've ended up with this rather nice method
fn send(&self, message: Message) -> ClientResult<DnsResponse>(which is derived fromclient::Client::query). In this method I'm callingDnsHandle::sendand I was wrapping its result in aClientResponse(which is whatclient::ClientHandle::queryends up doing) before sending it on totokio::runtime::Runtime::block_on(which is whatclient::Client::querydoes). I just didn't realize that I could replaceruntime.block_on(ClientResponse(future))withOk(runtime.block_on(future)?).I'm quite happy with that solution. For me getting my hands on the async stuff is pure gravy as I was planning to go that route anyway.