mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 18:38:09 +01:00
Tor port fixes (#215)
* Set bind for BCH when using tor * prepare: Set local tor control host when not in docker mode. * Unlink tor hosts from BSX_DOCKER_MODE and add BSX_LOCAL_TOR.
This commit is contained in:
@@ -247,18 +247,23 @@ def getWalletBinName(coin_id: int, coin_settings, default_name: str) -> str:
|
||||
) + (".exe" if os.name == "nt" else "")
|
||||
|
||||
|
||||
def getCoreBinArgs(coin_id: int, coin_settings, prepare=False):
|
||||
def getCoreBinArgs(coin_id: int, coin_settings, prepare=False, use_tor_proxy=False):
|
||||
extra_args = []
|
||||
if "config_filename" in coin_settings:
|
||||
extra_args.append("--conf=" + coin_settings["config_filename"])
|
||||
if "port" in coin_settings:
|
||||
extra_args.append("--port=" + str(int(coin_settings["port"])))
|
||||
if prepare is False and use_tor_proxy:
|
||||
if coin_id == Coins.BCH:
|
||||
# Without this BCH (27.1) will bind to the default BTC port, even with proxy set
|
||||
extra_args.append("--bind=127.0.0.1:" + str(int(coin_settings["port"])))
|
||||
else:
|
||||
extra_args.append("--port=" + str(int(coin_settings["port"])))
|
||||
|
||||
# BTC versions from v28 fail to start if the onionport is in use.
|
||||
# As BCH may use port 8334, disable it here.
|
||||
# When tor is enabled a bind option for the onionport will be added to bitcoin.conf.
|
||||
# https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-28.0.md?plain=1#L84
|
||||
if not prepare and coin_id == Coins.BTC:
|
||||
if prepare is False and use_tor_proxy is False and coin_id == Coins.BTC:
|
||||
port: int = coin_settings.get("port", 8333)
|
||||
extra_args.append(f"--bind=0.0.0.0:{port}")
|
||||
return extra_args
|
||||
@@ -435,7 +440,7 @@ def runClient(fp, data_dir, chain, start_only_coins):
|
||||
swap_client.log.info(f"Starting {display_name} daemon")
|
||||
|
||||
filename: str = getCoreBinName(coin_id, v, c + "d")
|
||||
extra_opts = getCoreBinArgs(coin_id, v)
|
||||
extra_opts = getCoreBinArgs(coin_id, v, use_tor_proxy=swap_client.use_tor_proxy)
|
||||
daemons.append(
|
||||
startDaemon(v["datadir"], v["bindir"], filename, opts=extra_opts)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user