From eff0e201f3d7f9c2150dbb4db46004ab910ad63d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Fri, 10 Feb 2023 09:12:09 +0200 Subject: [PATCH] cormorant: only use proxy when connecting to onion addresses --- .../sparrow/net/cormorant/bitcoind/BitcoindTransport.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindTransport.java b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindTransport.java index d306d67d..d5c19c22 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindTransport.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/cormorant/bitcoind/BitcoindTransport.java @@ -4,6 +4,7 @@ import com.github.arteam.simplejsonrpc.client.Transport; import com.sparrowwallet.drongo.Network; import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.io.Server; +import com.sparrowwallet.sparrow.net.Protocol; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,6 +24,7 @@ public class BitcoindTransport implements Transport { private static final Logger log = LoggerFactory.getLogger(BitcoindTransport.class); public static final String COOKIE_FILENAME = ".cookie"; + private final Server bitcoindServer; private URL bitcoindUrl; private File cookieFile; private Long cookieFileTimestamp; @@ -39,6 +41,7 @@ public class BitcoindTransport implements Transport { } private BitcoindTransport(Server bitcoindServer, String bitcoindWallet) { + this.bitcoindServer = bitcoindServer; try { this.bitcoindUrl = new URL(bitcoindServer.getUrl() + "/wallet/" + bitcoindWallet); } catch(MalformedURLException e) { @@ -49,7 +52,7 @@ public class BitcoindTransport implements Transport { @Override public String pass(String request) throws IOException { Proxy proxy = AppServices.getProxy(); - HttpURLConnection connection = proxy == null ? (HttpURLConnection)bitcoindUrl.openConnection() : (HttpURLConnection)bitcoindUrl.openConnection(proxy); + HttpURLConnection connection = proxy != null && Protocol.isOnionAddress(bitcoindServer) ? (HttpURLConnection)bitcoindUrl.openConnection(proxy) : (HttpURLConnection)bitcoindUrl.openConnection(); if(connection instanceof HttpsURLConnection httpsURLConnection) { SSLSocketFactory sslSocketFactory = getTrustAllSocketFactory();