diff --git a/cashu/tor/tor.py b/cashu/tor/tor.py index 4d810fc..995e282 100755 --- a/cashu/tor/tor.py +++ b/cashu/tor/tor.py @@ -9,7 +9,7 @@ from loguru import logger class TorProxy: - def __init__(self, keep_alive=False): + def __init__(self, keep_alive=False, dont_start=False): self.base_path = pathlib.Path(__file__).parent.resolve() self.platform = platform.system() self.keep_alive = 60 * 60 if keep_alive else 0 # seconds @@ -27,8 +27,7 @@ class TorProxy: logger.debug(f"Tor PID in tor.pid: {self.read_pid()}") logger.debug(f"Tor PID running: {self.signal_pid(self.read_pid())}") - if not self.tor_running: - logger.debug("Starting") + if not self.tor_running and not dont_start: self.run_daemon() @classmethod @@ -41,6 +40,7 @@ class TorProxy: def run_daemon(self): if not self.check_platform(): return + logger.debug("Starting Tor") cmd = [f"{self.tor_path()}", "--defaults-torrc", f"{self.tor_config_path()}"] if self.keep_alive and platform.system() != "Windows": cmd = ["timeout", f"{self.keep_alive}"] + cmd diff --git a/cashu/wallet/cli.py b/cashu/wallet/cli.py index cb0285c..3ec7cdd 100755 --- a/cashu/wallet/cli.py +++ b/cashu/wallet/cli.py @@ -72,7 +72,7 @@ def cli(ctx, host: str, walletname: str): ctx.obj["WALLET_NAME"] = walletname wallet = Wallet(ctx.obj["HOST"], os.path.join(CASHU_DIR, walletname)) - if TOR and not TorProxy().check_platform(): + if TOR and not TorProxy(dont_start=True).check_platform(): print( "WARNING: Your settings say TOR=true but the built-in Tor bundle is not supported on your system. Your IP will be visible to the mint! Please install Tor manually and set TOR=false and SOCKS_HOST=localhost and SOCKS_PORT=9050 in your Cashu config (recommended) or turn off Tor altogether by setting TOR=false (not recommended)." )