diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index 2691adf5a..8302cbdd2 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -225,25 +225,27 @@ class ElectrumXClient { Future checkElectrumAdapter() async { ({InternetAddress host, int port})? proxyInfo; - // If we're supposed to use Tor... + if (_prefs.torKillSwitch) { + // If the killswitch is set... + if (_torService.status != TorConnectionStatus.connected) { + // And Tor isn't connected, then we'll throw an exception. + throw Exception( + "Tor killswitch set but Tor is not connected, not connecting to Electrum adapter", + ); + } + } + if (_prefs.useTor) { - // But Tor isn't running... + // If we're supposed to use Tor... if (_torService.status != TorConnectionStatus.connected) { - // And the killswitch isn't set... + // But Tor isn't running... if (!_prefs.torKillSwitch) { - // Then we'll just proceed and connect to ElectrumX through - // clearnet at the bottom of this function. + // And the killswitch isn't set... + // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function. Logging.instance.w( "Tor preference set but Tor is not enabled, killswitch not set," " connecting to Electrum adapter through clearnet", ); - } else { - // ... But if the killswitch is set, then we throw an exception. - throw Exception( - "Tor preference and killswitch set but Tor is not enabled, " - "not connecting to Electrum adapter", - ); - // TODO [prio=low]: Try to start Tor. } } else { // Get the proxy info from the TorService. diff --git a/lib/utilities/connection_check/electrum_connection_check.dart b/lib/utilities/connection_check/electrum_connection_check.dart index 325cfa059..4943cf169 100644 --- a/lib/utilities/connection_check/electrum_connection_check.dart +++ b/lib/utilities/connection_check/electrum_connection_check.dart @@ -20,25 +20,29 @@ Future checkElectrumServer({ ({InternetAddress host, int port})? proxyInfo; try { - // If we're supposed to use Tor... + if (_prefs.torKillSwitch) { + // If the killswitch is set... + if (_torService.status != TorConnectionStatus.connected) { + // And Tor isn't connected, then we'll throw an exception. + throw Exception( + "Tor killswitch set but Tor is not connected, not connecting to Electrum adapter", + ); + } + } + if (_prefs.useTor) { - // But Tor isn't running... + // If we're supposed to use Tor... if (_torService.status != TorConnectionStatus.connected) { - // And the killswitch isn't set... + // But Tor isn't connected... if (!_prefs.torKillSwitch) { + // And the killswitch isn't set... // Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function. Logging.instance.w( "Tor preference set but Tor is not enabled, killswitch not set, connecting to Electrum adapter through clearnet", ); - } else { - // ... But if the killswitch is set, then we throw an exception. - throw Exception( - "Tor preference and killswitch set but Tor is not enabled, not connecting to Electrum adapter", - ); - // TODO [prio=low]: Try to start Tor. } } else { - // Get the proxy info from the TorService. + // If Tor is connected, get the proxy info from the TorService. proxyInfo = _torService.getProxyInfo(); } } diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 395e5ecd6..f13605a36 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -459,7 +459,7 @@ class Prefs extends ChangeNotifier { // tor - bool _torKillswitch = true; + bool _torKillswitch = false; bool get torKillSwitch => _torKillswitch;