mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
cormorant: only use proxy when connecting to onion addresses
This commit is contained in:
parent
58d10cbba4
commit
eff0e201f3
1 changed files with 4 additions and 1 deletions
|
@ -4,6 +4,7 @@ import com.github.arteam.simplejsonrpc.client.Transport;
|
||||||
import com.sparrowwallet.drongo.Network;
|
import com.sparrowwallet.drongo.Network;
|
||||||
import com.sparrowwallet.sparrow.AppServices;
|
import com.sparrowwallet.sparrow.AppServices;
|
||||||
import com.sparrowwallet.sparrow.io.Server;
|
import com.sparrowwallet.sparrow.io.Server;
|
||||||
|
import com.sparrowwallet.sparrow.net.Protocol;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ public class BitcoindTransport implements Transport {
|
||||||
private static final Logger log = LoggerFactory.getLogger(BitcoindTransport.class);
|
private static final Logger log = LoggerFactory.getLogger(BitcoindTransport.class);
|
||||||
public static final String COOKIE_FILENAME = ".cookie";
|
public static final String COOKIE_FILENAME = ".cookie";
|
||||||
|
|
||||||
|
private final Server bitcoindServer;
|
||||||
private URL bitcoindUrl;
|
private URL bitcoindUrl;
|
||||||
private File cookieFile;
|
private File cookieFile;
|
||||||
private Long cookieFileTimestamp;
|
private Long cookieFileTimestamp;
|
||||||
|
@ -39,6 +41,7 @@ public class BitcoindTransport implements Transport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private BitcoindTransport(Server bitcoindServer, String bitcoindWallet) {
|
private BitcoindTransport(Server bitcoindServer, String bitcoindWallet) {
|
||||||
|
this.bitcoindServer = bitcoindServer;
|
||||||
try {
|
try {
|
||||||
this.bitcoindUrl = new URL(bitcoindServer.getUrl() + "/wallet/" + bitcoindWallet);
|
this.bitcoindUrl = new URL(bitcoindServer.getUrl() + "/wallet/" + bitcoindWallet);
|
||||||
} catch(MalformedURLException e) {
|
} catch(MalformedURLException e) {
|
||||||
|
@ -49,7 +52,7 @@ public class BitcoindTransport implements Transport {
|
||||||
@Override
|
@Override
|
||||||
public String pass(String request) throws IOException {
|
public String pass(String request) throws IOException {
|
||||||
Proxy proxy = AppServices.getProxy();
|
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) {
|
if(connection instanceof HttpsURLConnection httpsURLConnection) {
|
||||||
SSLSocketFactory sslSocketFactory = getTrustAllSocketFactory();
|
SSLSocketFactory sslSocketFactory = getTrustAllSocketFactory();
|
||||||
|
|
Loading…
Reference in a new issue