Merge pull request #7279 from alvasw/DnsLookupTor_Close_socket_after_usage

DnsLookupTor: Close socket after usage
This commit is contained in:
Alejandro García 2024-11-05 05:06:51 +00:00 committed by GitHub
commit 1baf67ef27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -60,16 +60,14 @@ public class DnsLookupTor {
* Performs DNS lookup and returns a single InetAddress
*/
public static InetAddress lookup(Socks5Proxy proxy, String host) throws DnsLookupException {
try {
// note: This is creating a new connection to our proxy, without any authentication.
// This works fine when connecting to bisq's internal Tor proxy, but
// would fail if user has configured an external proxy that requires auth.
// It would be much better to use the already connected proxy socket, but when I
// tried that I get weird errors and the lookup fails.
//
// So this is an area for future improvement.
Socket proxySocket = new Socket(proxy.getInetAddress(), proxy.getPort());
// note: This is creating a new connection to our proxy, without any authentication.
// This works fine when connecting to bisq's internal Tor proxy, but
// would fail if user has configured an external proxy that requires auth.
// It would be much better to use the already connected proxy socket, but when I
// tried that I get weird errors and the lookup fails.
//
// So this is an area for future improvement.
try (Socket proxySocket = new Socket(proxy.getInetAddress(), proxy.getPort())) {
proxySocket.getOutputStream().write(new byte[]{b('\u0005'), b('\u0001'), b('\u0000')});
byte[] buf = new byte[2];
//noinspection ResultOfMethodCallIgnored