mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +00:00
add config property autoSwitchProxy to disable automatic proxy switching on failure, and improve tor connection failure message
This commit is contained in:
parent
153815d9e3
commit
d84f3bf887
4 changed files with 15 additions and 2 deletions
|
@ -326,7 +326,7 @@ public class AppServices {
|
|||
}
|
||||
}
|
||||
|
||||
if(failEvent.getSource().getException() instanceof ProxyServerException && Config.get().isUseProxy() && Config.get().requiresTor()) {
|
||||
if(failEvent.getSource().getException() instanceof ProxyServerException && Config.get().isUseProxy() && Config.get().isAutoSwitchProxy() && Config.get().requiresTor()) {
|
||||
Config.get().setUseProxy(false);
|
||||
Platform.runLater(() -> restartService(torService));
|
||||
return;
|
||||
|
|
|
@ -70,6 +70,7 @@ public class Config {
|
|||
private File electrumServerCert;
|
||||
private boolean useProxy;
|
||||
private String proxyServer;
|
||||
private boolean autoSwitchProxy = true;
|
||||
private int maxServerTimeout = DEFAULT_MAX_TIMEOUT;
|
||||
private int maxPageSize = DEFAULT_PAGE_SIZE;
|
||||
private boolean usePayNym;
|
||||
|
@ -605,6 +606,15 @@ public class Config {
|
|||
flush();
|
||||
}
|
||||
|
||||
public boolean isAutoSwitchProxy() {
|
||||
return autoSwitchProxy;
|
||||
}
|
||||
|
||||
public void setAutoSwitchProxy(boolean autoSwitchProxy) {
|
||||
this.autoSwitchProxy = autoSwitchProxy;
|
||||
flush();
|
||||
}
|
||||
|
||||
public int getMaxServerTimeout() {
|
||||
return maxServerTimeout;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@ public class TorTcpTransport extends TcpTransport {
|
|||
throw new IllegalStateException("Can't create Tor socket, Tor is not running");
|
||||
}
|
||||
|
||||
socket = new TorSocket(server.getHost(), server.getPort(), "sparrow");
|
||||
socket = new TorSocket(server.getHost(), server.getPortOrDefault(Protocol.TCP.getDefaultPort()), "sparrow");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,6 +329,7 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
setElectrumServerInConfig(config);
|
||||
electrumCertificate.setDisable(!newValue);
|
||||
electrumCertificateSelect.setDisable(!newValue);
|
||||
electrumPort.setPromptText(newValue ? "e.g. 50002" : "e.g. 50001");
|
||||
});
|
||||
|
||||
electrumCertificate.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
|
@ -660,6 +661,8 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
reason += "\nIs a Tor proxy already running on port " + TorService.PROXY_PORT + "?";
|
||||
} else if(reason != null && (reason.contains("Check if Bitcoin Core is running") || reason.contains("Could not connect to Bitcoin Core RPC"))) {
|
||||
reason += "\n\nSee https://sparrowwallet.com/docs/connect-node.html";
|
||||
} else if(reason != null && (reason.startsWith("Cannot connect to hidden service"))) {
|
||||
reason += " on the server. Check that the onion address and port are correct, and that both Tor and the Electrum server are running on the node. Usually SSL is not enabled, and the port is 50001.";
|
||||
}
|
||||
|
||||
testResults.setText("Could not connect:\n\n" + reason);
|
||||
|
|
Loading…
Reference in a new issue