mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-24 18:55:55 +03:00
[GH-ISSUE #1335] Ability to call setsockopt on resolver's underlying DNS client #652
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#652
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 @zonyitoo on GitHub (Dec 29, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1335
Is your feature request related to a problem? Please describe.
I was making a proxy server and using trust-dns to resolves remote servers' domain names. To distinguish proxy servers' outbound connections, I set
SO_MARKoption on sockets.But there is no way to set
SO_MARKon trust-dns-resolver's internal connection, which specifically is:github.com/bluejekyll/trust-dns@58b9ec9885/crates/resolver/src/name_server/connection_provider.rs (L106-L206)Without the ability to set
SO_MARKor other related options, likeSO_BINDTODEVICE, data sent from trust-dns-resolver will cause infinity loops:Describe the solution you'd like
SO_MARK,SO_BINDTODEVICEtoResolverOptsGenericConnectionProvider.Describe alternatives you've considered
Copy
connection_provider.rsand customize my own version ofConnectionProvider@bluejekyll commented on GitHub (Jan 5, 2021):
I think we could provide a way to register hooks that would give access for this? Maybe we should reconsider the ConnectionProvider interface all together?
@zonyitoo commented on GitHub (Jan 5, 2021):
A simple solution, add several member functions for
ConnectionProviderIt helps because I just only need to copy
impl<R> ConnectionProvider for GenericConnectionProvider<R>rather than the whole file.Some extra options have to be stored in the instance of
ConnectionProviderandRuntimeProvider, such asmark,iface, that have to be set beforeconnect()but afterbind().@djc commented on GitHub (Jan 5, 2021):
I don't really like the
ConnectionProviderinterface, it feels very complex. What goal was it supposed to solve again?I would think more about something like r2d2/bb8's
ConnectionCustomizertrait:https://docs.rs/bb8/0.7.0/bb8/trait.CustomizeConnection.html
(Not sure it needs to be async for our intended usage.)
@zonyitoo commented on GitHub (Jan 5, 2021):
CustomizeConnectionis good, buton_acquirewill not work forSO_MARKandSO_BINDTODEVICE, which have to be called beforeconnect()and afterbind().On the otherhand, for some use cases, a
TcpStreamhave to callbind()on a specificIpAddrbeforeconnect()(also works forUdpSocket), which is a platform independent way to specify which interface should be used for sending network packets.@djc commented on GitHub (Jan 5, 2021):
Sorry, I didn't mean it that literally. More like:
@djc commented on GitHub (Jan 5, 2021):
(To make sure we do the right thing, we could have several hooks, e.g.
before_bind()orafter_connect()?)@zonyitoo commented on GitHub (Jan 5, 2021):
For TLS, HTTPS, mDNS, you may need more like
before_tls, .... :(@zonyitoo commented on GitHub (Jan 5, 2021):
How about customizing the underlying connection, for example, send queries via an
UnixDatagramorUnixStream.PS: This is not a common use case, just for discussion.
@bluejekyll commented on GitHub (Jan 5, 2021):
The explicit goal of
ConnectionProviderwas to allowed for a completely mocked version to allow for unit testing without establishing io for test scenarios. It allows us to test various situations easier than constructing those scenarios over actual socket based connections.I’m happy for us to consider it’s replacement/enhancement, but keeping the testability is my primary goal, so however we change it, I want to maintain that feature.
@zonyitoo commented on GitHub (Aug 22, 2021):
After half a year I am back here and ping @bluejekyll again about this feature.
I am building a VPN service, which will require all requests sent by this program could be routed properly to its destination interface. I have solved all the other connections except trust-dns-resolver's.
I have tried some ideas on the current source code but it felt so ugly. Do you have any suggestion about how to fulfill this goal?
@bluejekyll commented on GitHub (Dec 31, 2021):
This is partially addressed in #1586
@XOR-op commented on GitHub (Dec 20, 2022):
This fix does not work for Linux, which has a Weak ES Model by default (see here).
@XOR-op commented on GitHub (Mar 5, 2023):
@zonyitoo With the latest commits, this issue should be addressed.
@zonyitoo commented on GitHub (Mar 5, 2023):
Great! Could you add a sample code in
"examples"?@XOR-op commented on GitHub (Mar 6, 2023):
You can check out my new PR for more details.
@zonyitoo commented on GitHub (Mar 6, 2023):
Awesome, looking forward for the next release!
@zonyitoo commented on GitHub (Mar 12, 2023):
@bluejekyll When would it be the next release?
@lilydjwg commented on GitHub (Apr 11, 2024):
@bluejekyll bind address is different than bind interface, because interface address changes, especially with IPv6. I can catch the "Cannot assign requested address" error and recreate the client with a new address, but I can't tell the client to bind to a different address for the next connection because it's no longer preferred.
Or am I mistaken? Does hickory-dns do the reconnect thing, or is it me? I'll check.
Update: I now recreate udp clients and only reuse tcp & http2 ones (until they errors). Still I can't get the socket so I have to select an address myself.