Skip to content

Commit be0ae4c

Browse files
committed
network: reset server if both auto_connect and oneserver are enabled, remove redundant check.
1 parent 7138db6 commit be0ae4c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

electrum/network.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,9 @@ def _init_parameters_from_config(self) -> None:
519519
self.auto_connect = self.config.NETWORK_AUTO_CONNECT
520520
if self.auto_connect and self.config.NETWORK_ONESERVER:
521521
# enabling both oneserver and auto_connect doesn't really make sense
522-
# assume oneserver is enabled for privacy reasons, disable auto_connect
523-
self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect".')
522+
# assume oneserver is enabled for privacy reasons, disable auto_connect and assume server is unpredictable
523+
self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect" and resetting "server".')
524+
self.config.NETWORK_SERVER = "" # let _set_default_server set harmless default (localhost)
524525
self.auto_connect = False
525526

526527
self._set_default_server()
@@ -695,14 +696,8 @@ async def set_parameters(self, net_params: NetworkParameters):
695696
int(proxy['port'])
696697
except Exception:
697698
return
698-
auto_connect = net_params.auto_connect
699-
if auto_connect and net_params.oneserver:
700-
# enabling both oneserver and auto_connect doesn't really make sense
701-
# assume oneserver is enabled for privacy reasons, disable auto_connect
702-
self.logger.warning(f'both "oneserver" and "auto_connect" options enabled, disabling "auto_connect".')
703-
auto_connect = False
704699

705-
self.config.NETWORK_AUTO_CONNECT = auto_connect
700+
self.config.NETWORK_AUTO_CONNECT = net_params.auto_connect
706701
self.config.NETWORK_ONESERVER = net_params.oneserver
707702
self.config.NETWORK_PROXY = proxy_str
708703
self.config.NETWORK_PROXY_USER = proxy_user

0 commit comments

Comments
 (0)