From 617ad380c04d6571d9ecbeceaafaf83a92ef88f8 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 15 Jan 2025 15:22:15 +0200 Subject: [PATCH] improve socket address resolution handling --- .../sparrowwallet/sparrow/net/ProxyTcpOverTlsTransport.java | 2 +- src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ProxyTcpOverTlsTransport.java b/src/main/java/com/sparrowwallet/sparrow/net/ProxyTcpOverTlsTransport.java index 325a08f9..d865f874 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ProxyTcpOverTlsTransport.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ProxyTcpOverTlsTransport.java @@ -32,7 +32,7 @@ public class ProxyTcpOverTlsTransport extends TcpOverTlsTransport { protected void createSocket() throws IOException { InetSocketAddress proxyAddr = new InetSocketAddress(proxy.getHost(), proxy.getPortOrDefault(DEFAULT_PROXY_PORT)); socket = new Socket(new Proxy(Proxy.Type.SOCKS, proxyAddr)); - socket.connect(new InetSocketAddress(server.getHost(), server.getPortOrDefault(getDefaultPort()))); + socket.connect(InetSocketAddress.createUnresolved(server.getHost(), server.getPortOrDefault(getDefaultPort()))); socket = sslSocketFactory.createSocket(socket, proxy.getHost(), proxy.getPortOrDefault(DEFAULT_PROXY_PORT), true); startHandshake((SSLSocket)socket); } diff --git a/src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java b/src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java index e3a10856..8a10494a 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/TcpTransport.java @@ -268,7 +268,9 @@ public class TcpTransport implements CloseableTransport, TimeoutCounter { protected void createSocket() throws IOException { socket = socketFactory.createSocket(); - socket.connect(new InetSocketAddress(server.getHost(), server.getPortOrDefault(getDefaultPort()))); + socket.connect(socketFactory instanceof ProxySocketFactory ? + InetSocketAddress.createUnresolved(server.getHost(), server.getPortOrDefault(getDefaultPort())) : + new InetSocketAddress(server.getHost(), server.getPortOrDefault(getDefaultPort()))); } protected int getDefaultPort() {