GeezerVison is showing github.com — DNS over SOCKS · Issue #341 · dnsjava/dnsjava
DescriptionHi
I would like to suggest the addition of SOCKS5 proxy support for TCP and UDP.
This would be beneficial for routing DNS traffic through an internal network.
Is there interest in this? I would like to discuss this further. Activityibauersachs commented on Sep 23, 2024 Hey,
Sure, support for this would be welcome.
However, I don't want a dependency on another library and ideally it would be possible to reuse existing APIs of dnsjava (TcpIoClient/UdpIoClient).
Feel free to create a PR, but I won't be able to review anything in the following weeks.
Thanks,
Ingo tw-datascientist commented on Sep 24, 2024 Sounds good.
My plan is to add an additional constructor for SimpleResolver to pass the necessary parameters and add the SOCKS Handshake here in SimpleResolver.java in the sendAsync method.
CompletableFuture<byte[]> result;
if (tcp) {
// add SOCKS5 Handshake for TCP
result =
ioClientFactory
.createOrGetTcpClient()
.sendAndReceiveTcp(localAddress, address, query, out, timeoutValue);
} else {
// add SOCKS5 Handshake for UDP
result =
ioClientFactory
.createOrGetUdpClient()
.sendAndReceiveUdp(localAddress, address, query, out, udpSize, timeoutValue);
}
Yes. I should be able to use the ioClientFactory for the SOCKS Handshake for TCP and UDP and implement it without any additional dependencies.
I'll prepare a PR. ibauersachs commented on Oct 1, 2024 Please try to avoid any changes in SimpleResolver. If the handshake is in the IoClients anyway, I don't think it would be neccessary. tw-datascientist commented on Oct 2, 2024 Hi @ibauersachs,
I have a first working solution. master...tw-datascientist:dnsjava:master
Yes, I plan to refactor the changes into the IoClients. Handling UDP is tricky. I have to strip the SOCKS UDP header from the UDP reply. And the TCP connection to setup the UDP associate have to stay open till the UDP transmission has finished. Otherwise I get java.net.PortUnreachableException.
Oct 2 14:46:43 (1727880403.768883) sockd[33]: info: pass(1): tcp/accept [: 172.30.0.2.49904 172.30.0.3.1080
Oct 2 14:46:43 (1727880403.769914) sockd[16]: info: pass(1): udp/udpassociate [: 0.0.0.0.0 172.30.0.3.10000
Oct 2 14:46:43 (1727880403.774654) sockd[37]: info: pass(1): udp/udpassociate -: 172.30.0.2.60384 172.30.0.3.10000 -> 172.30.0.3.60384 1.1.1.1.53 (39)
Oct 2 14:46:43 (1727880403.785650) sockd[37]: info: pass(2): udp/udpreply -: 1.1.1.1.53 172.30.0.3.60384 -> 172.30.0.3.10000 172.30.0.2.60384 (55)
Oct 2 14:46:43 (1727880403.786366) sockd[37]: info: pass(1): udp/udpassociate ]: 65/1 -> 172.30.0.2.60384 172.30.0.3.10000 -> 49/1, 39/1 -> 172.30.0.3.60384 1.1.1.1.53 -> 55/1: local client closed. Session duration: 0s
Oct 2 14:46:43 (1727880403.786378) sockd[37]: info: pass(1): tcp/accept ]: 65 -> 172.30.0.2.49904 172.30.0.3.1080 -> 39: local client closed. Session duration: 0s
My guess is that the best approach is to move this logic into the processReadyKey method in NioUdpClient.java. tw-datascientist commented on Oct 3, 2024
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|