mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-24 12:46:45 +00:00
try proxy setting if internal tor cant start
This commit is contained in:
parent
7c6daf2e11
commit
8b7d1e6888
1 changed files with 22 additions and 0 deletions
|
@ -151,6 +151,8 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
|
||||
private Boolean useSslOriginal;
|
||||
|
||||
private Boolean useProxyOriginal;
|
||||
|
||||
@Override
|
||||
public void initializeView(Config config) {
|
||||
EventManager.get().register(this);
|
||||
|
@ -424,6 +426,18 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
torService.cancel();
|
||||
testResults.appendText("\nTor failed to start");
|
||||
showConnectionFailure(workerStateEvent.getSource().getException());
|
||||
|
||||
Throwable exception = workerStateEvent.getSource().getException();
|
||||
if(Config.get().getServerType() == ServerType.ELECTRUM_SERVER &&
|
||||
exception.getCause() != null && exception.getCause() instanceof TorControlError && exception.getCause().getMessage().contains("Failed to bind") &&
|
||||
useProxyOriginal == null && !useProxy.isSelected() && proxyHost.getText().isEmpty() && proxyPort.getText().isEmpty()) {
|
||||
useProxy.setSelected(true);
|
||||
proxyHost.setText("localhost");
|
||||
proxyPort.setText("9050");
|
||||
useProxyOriginal = false;
|
||||
testResults.appendText("\n\nAssuming Tor proxy is running on port 9050 and trying again...");
|
||||
startElectrumConnection();
|
||||
}
|
||||
});
|
||||
|
||||
torService.start();
|
||||
|
@ -448,6 +462,7 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
getMasterController().reconnectOnClosingProperty().set(true);
|
||||
Config.get().setMode(Mode.ONLINE);
|
||||
connectionService.cancel();
|
||||
useProxyOriginal = null;
|
||||
});
|
||||
connectionService.setOnFailed(workerStateEvent -> {
|
||||
EventManager.get().unregister(connectionService);
|
||||
|
@ -475,6 +490,13 @@ public class ServerPreferencesController extends PreferencesDetailController {
|
|||
useSslOriginal = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(useProxyOriginal != null && !useProxyOriginal) {
|
||||
useProxy.setSelected(false);
|
||||
proxyHost.setText("");
|
||||
proxyPort.setText("");
|
||||
useProxyOriginal = null;
|
||||
}
|
||||
});
|
||||
connectionService.start();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue