mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-22 19:49:20 +00:00
prepare: Avoid setting tor mode for commands that only modify config.
This commit is contained in:
parent
d7da532111
commit
7bf5f7ddfa
2 changed files with 8 additions and 6 deletions
|
@ -224,12 +224,13 @@ class BasicSwap(BaseApp):
|
||||||
SwapTypes.XMR_SWAP: xmr_swap_1.XmrSwapInterface(),
|
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)
|
super().__init__(fp, data_dir, settings, chain, log_name)
|
||||||
|
|
||||||
v = __version__.split('.')
|
v = __version__.split('.')
|
||||||
self._version = struct.pack('>HHH', int(v[0]), int(v[1]), int(v[2]))
|
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_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_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)
|
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]['walletrpctimeout'] = chain_client_settings.get('walletrpctimeout', 120)
|
||||||
self.coin_clients[coin]['walletrpctimeoutlong'] = chain_client_settings.get('walletrpctimeoutlong', 600)
|
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.selectXMRRemoteDaemon(coin)
|
||||||
|
|
||||||
self.coin_clients[coin]['walletrpchost'] = chain_client_settings.get('walletrpchost', '127.0.0.1')
|
self.coin_clients[coin]['walletrpchost'] = chain_client_settings.get('walletrpchost', '127.0.0.1')
|
||||||
|
|
|
@ -1144,7 +1144,7 @@ def test_particl_encryption(data_dir, settings, chain, use_tor_proxy):
|
||||||
daemon_args = ['-noconnect', '-nodnsseed', '-nofindpeers', '-nostaking']
|
daemon_args = ['-noconnect', '-nodnsseed', '-nofindpeers', '-nostaking']
|
||||||
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
|
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
|
||||||
try:
|
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:
|
if not swap_client.use_tor_proxy:
|
||||||
# Cannot set -bind or -whitebind together with -listen=0
|
# Cannot set -bind or -whitebind together with -listen=0
|
||||||
daemon_args.append('-nolisten')
|
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:
|
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
|
||||||
try:
|
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:
|
if not swap_client.use_tor_proxy:
|
||||||
# Cannot set -bind or -whitebind together with -listen=0
|
# Cannot set -bind or -whitebind together with -listen=0
|
||||||
daemon_args.append('-nolisten')
|
daemon_args.append('-nolisten')
|
||||||
|
@ -1476,8 +1476,9 @@ def main():
|
||||||
if use_tor_proxy and extra_opts.get('no_tor_proxy', False):
|
if use_tor_proxy and extra_opts.get('no_tor_proxy', False):
|
||||||
exitWithError('Can\'t use --usetorproxy and --notorproxy together')
|
exitWithError('Can\'t use --usetorproxy and --notorproxy together')
|
||||||
|
|
||||||
# Check config to see if tor is enabled
|
# Automatically enable tor for certain commands if it's set in basicswap config
|
||||||
if not use_tor_proxy and os.path.exists(config_path):
|
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 = load_config(config_path)
|
||||||
settings_use_tor = settings.get('use_tor', False)
|
settings_use_tor = settings.get('use_tor', False)
|
||||||
if settings_use_tor:
|
if settings_use_tor:
|
||||||
|
|
Loading…
Reference in a new issue