From be0ae4c1c902e8c4afa2465d165408a4fc5a56b8 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Mon, 14 Oct 2024 11:27:25 +0200 Subject: [PATCH] network: reset server if both auto_connect and oneserver are enabled, remove redundant check. --- electrum/network.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/electrum/network.py b/electrum/network.py index 5e3bbda721b1..db8a2ecb3c2e 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -519,8 +519,9 @@ def _init_parameters_from_config(self) -> None: self.auto_connect = self.config.NETWORK_AUTO_CONNECT if self.auto_connect and self.config.NETWORK_ONESERVER: # enabling both oneserver and auto_connect doesn't really make sense - # assume oneserver is enabled for privacy reasons, disable auto_connect - self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect".') + # assume oneserver is enabled for privacy reasons, disable auto_connect and assume server is unpredictable + self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect" and resetting "server".') + self.config.NETWORK_SERVER = "" # let _set_default_server set harmless default (localhost) self.auto_connect = False self._set_default_server() @@ -695,14 +696,8 @@ async def set_parameters(self, net_params: NetworkParameters): int(proxy['port']) except Exception: return - auto_connect = net_params.auto_connect - if auto_connect and net_params.oneserver: - # enabling both oneserver and auto_connect doesn't really make sense - # assume oneserver is enabled for privacy reasons, disable auto_connect - self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect".') - auto_connect = False - self.config.NETWORK_AUTO_CONNECT = auto_connect + self.config.NETWORK_AUTO_CONNECT = net_params.auto_connect self.config.NETWORK_ONESERVER = net_params.oneserver self.config.NETWORK_PROXY = proxy_str self.config.NETWORK_PROXY_USER = proxy_user