Skip to content

Commit

Permalink
network: reset server if both auto_connect and oneserver are enabled,…
Browse files Browse the repository at this point in the history
… remove redundant check.
  • Loading branch information
accumulator committed Oct 14, 2024
1 parent 0cf1dae commit b15a2e1
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions electrum/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b15a2e1

Please sign in to comment.