mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 20:29:57 +00:00
implement tor killswitch
comment update
This commit is contained in:
parent
cf27dd9252
commit
d317bc5e8b
1 changed files with 59 additions and 43 deletions
|
@ -158,11 +158,24 @@ class ElectrumX {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _checkRpcClient() {
|
void _checkRpcClient() {
|
||||||
|
// If we're supposed to use Tor...
|
||||||
if (_prefs.useTor) {
|
if (_prefs.useTor) {
|
||||||
|
// But Tor isn't enabled...
|
||||||
if (!_torService.enabled) {
|
if (!_torService.enabled) {
|
||||||
throw Exception("Tor is not enabled");
|
// And the killswitch isn't set...
|
||||||
|
if (!_prefs.torKillswitch) {
|
||||||
|
// Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function.
|
||||||
|
Logging.instance.log(
|
||||||
|
"Tor preference set but Tor is not enabled, killswitch not set, connecting to ElectrumX through clearnet",
|
||||||
|
level: LogLevel.Warning,
|
||||||
|
);
|
||||||
|
} 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 ElectrumX");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Get the proxy info from the TorService.
|
||||||
final proxyInfo = _torService.proxyInfo;
|
final proxyInfo = _torService.proxyInfo;
|
||||||
|
|
||||||
if (currentFailoverIndex == -1) {
|
if (currentFailoverIndex == -1) {
|
||||||
|
@ -189,7 +202,11 @@ class ElectrumX {
|
||||||
reason: "Tor proxyInfo does not match current info",
|
reason: "Tor proxyInfo does not match current info",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (currentFailoverIndex == -1) {
|
if (currentFailoverIndex == -1) {
|
||||||
_rpcClient ??= JsonRPC(
|
_rpcClient ??= JsonRPC(
|
||||||
host: host,
|
host: host,
|
||||||
|
@ -208,7 +225,6 @@ class ElectrumX {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Send raw rpc command
|
/// Send raw rpc command
|
||||||
Future<dynamic> request({
|
Future<dynamic> request({
|
||||||
|
|
Loading…
Reference in a new issue