mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-02-04 08:14:21 +01:00
warning
This commit is contained in:
@@ -31,7 +31,15 @@ class TorProxy:
|
||||
logger.debug("Starting")
|
||||
self.run_daemon()
|
||||
|
||||
def check_platform(self):
|
||||
if platform.system() == "Linux":
|
||||
if platform.machine() != "x86_64":
|
||||
return False
|
||||
return True
|
||||
|
||||
def run_daemon(self):
|
||||
if not self.check_platform():
|
||||
return
|
||||
cmd = [
|
||||
f"{self.tor_path()}",
|
||||
"--defaults-torrc",
|
||||
@@ -92,6 +100,8 @@ class TorProxy:
|
||||
return self.tor_proc and self.tor_proc.poll() is None
|
||||
|
||||
def wait_until_startup(self, verbose=False):
|
||||
if not self.check_platform():
|
||||
return
|
||||
if self.is_port_open():
|
||||
return
|
||||
if self.tor_proc is None:
|
||||
|
||||
@@ -62,10 +62,16 @@ class LedgerAPI:
|
||||
def _set_requests(self):
|
||||
s = requests.Session()
|
||||
s.headers.update({"Client-version": VERSION})
|
||||
socks_host, socks_port = None, None
|
||||
if TOR:
|
||||
tor = TorProxy(keep_alive=True)
|
||||
tor.wait_until_startup(verbose=True)
|
||||
socks_host, socks_port = "localhost", 9050
|
||||
if not tor.check_platform():
|
||||
print(
|
||||
"WARNING: The built-in Tor bundle is not supported on your System. Please install Tor and set the SOCKS_HOST and SOCKS_PORT variables in your Cashu configuration .env file (recommended) or turn off tor by setting TOR=false (not recommended)."
|
||||
)
|
||||
else:
|
||||
tor.wait_until_startup(verbose=True)
|
||||
socks_host, socks_port = "localhost", 9050
|
||||
else:
|
||||
socks_host, socks_port = SOCKS_HOST, SOCKS_PORT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user