Browse Source

prepare: Avoid setting tor mode for commands that only modify config.

tor_fixes
tecnovert 3 months ago
parent
commit
7bf5f7ddfa
  1. 5
      basicswap/basicswap.py
  2. 9
      bin/basicswap_prepare.py

5
basicswap/basicswap.py

@ -224,12 +224,13 @@ class BasicSwap(BaseApp):
SwapTypes.XMR_SWAP: xmr_swap_1.XmrSwapInterface(),
}
def __init__(self, fp, data_dir, settings, chain, log_name='BasicSwap'):
def __init__(self, fp, data_dir, settings, chain, log_name='BasicSwap', transient_instance=False):
super().__init__(fp, data_dir, settings, chain, log_name)
v = __version__.split('.')
self._version = struct.pack('>HHH', int(v[0]), int(v[1]), int(v[2]))
self._transient_instance = transient_instance
self.check_progress_seconds = self.get_int_setting('check_progress_seconds', 60, 1, 10 * 60)
self.check_watched_seconds = self.get_int_setting('check_watched_seconds', 60, 1, 10 * 60)
self.check_expired_seconds = self.get_int_setting('check_expired_seconds', 5 * 60, 1, 10 * 60)
@ -499,7 +500,7 @@ class BasicSwap(BaseApp):
self.coin_clients[coin]['walletrpctimeout'] = chain_client_settings.get('walletrpctimeout', 120)
self.coin_clients[coin]['walletrpctimeoutlong'] = chain_client_settings.get('walletrpctimeoutlong', 600)
if chain_client_settings.get('automatically_select_daemon', False):
if not self._transient_instance and chain_client_settings.get('automatically_select_daemon', False):
self.selectXMRRemoteDaemon(coin)
self.coin_clients[coin]['walletrpchost'] = chain_client_settings.get('walletrpchost', '127.0.0.1')

9
bin/basicswap_prepare.py

@ -1144,7 +1144,7 @@ def test_particl_encryption(data_dir, settings, chain, use_tor_proxy):
daemon_args = ['-noconnect', '-nodnsseed', '-nofindpeers', '-nostaking']
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
try:
swap_client = BasicSwap(fp, data_dir, settings, chain)
swap_client = BasicSwap(fp, data_dir, settings, chain, transient_instance=True)
if not swap_client.use_tor_proxy:
# Cannot set -bind or -whitebind together with -listen=0
daemon_args.append('-nolisten')
@ -1185,7 +1185,7 @@ def initialise_wallets(particl_wallet_mnemonic, with_coins, data_dir, settings,
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
try:
swap_client = BasicSwap(fp, data_dir, settings, chain)
swap_client = BasicSwap(fp, data_dir, settings, chain, transient_instance=True)
if not swap_client.use_tor_proxy:
# Cannot set -bind or -whitebind together with -listen=0
daemon_args.append('-nolisten')
@ -1476,8 +1476,9 @@ def main():
if use_tor_proxy and extra_opts.get('no_tor_proxy', False):
exitWithError('Can\'t use --usetorproxy and --notorproxy together')
# Check config to see if tor is enabled
if not use_tor_proxy and os.path.exists(config_path):
# Automatically enable tor for certain commands if it's set in basicswap config
if not (initwalletsonly or enable_tor or disable_tor or disable_coin) and \
not use_tor_proxy and os.path.exists(config_path):
settings = load_config(config_path)
settings_use_tor = settings.get('use_tor', False)
if settings_use_tor:

Loading…
Cancel
Save