mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-25 23:39:43 -05:00
Find the proper tor binary in onionshare-cli for macOS
This commit is contained in:
parent
68347039c9
commit
d9153758cd
@ -93,17 +93,26 @@ class Common:
|
||||
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
||||
elif self.platform == "Darwin":
|
||||
base_path = os.path.dirname(
|
||||
os.path.dirname(os.path.dirname(self.get_resource_path("")))
|
||||
)
|
||||
tor_path = os.path.join(base_path, "Resources", "Tor", "tor")
|
||||
tor_geo_ip_file_path = os.path.join(base_path, "Resources", "Tor", "geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(
|
||||
base_path, "Resources", "Tor", "geoip6"
|
||||
)
|
||||
obfs4proxy_file_path = os.path.join(
|
||||
base_path, "Resources", "Tor", "obfs4proxy"
|
||||
)
|
||||
if os.path.basename(sys.argv[0]) == "onionshare-cli":
|
||||
tor_path = shutil.which("tor")
|
||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
||||
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
|
||||
else:
|
||||
base_path = os.path.dirname(
|
||||
os.path.dirname(os.path.dirname(self.get_resource_path("")))
|
||||
)
|
||||
tor_path = os.path.join(base_path, "Resources", "Tor", "tor")
|
||||
tor_geo_ip_file_path = os.path.join(
|
||||
base_path, "Resources", "Tor", "geoip"
|
||||
)
|
||||
tor_geo_ipv6_file_path = os.path.join(
|
||||
base_path, "Resources", "Tor", "geoip6"
|
||||
)
|
||||
obfs4proxy_file_path = os.path.join(
|
||||
base_path, "Resources", "Tor", "obfs4proxy"
|
||||
)
|
||||
elif self.platform == "BSD":
|
||||
tor_path = "/usr/local/bin/tor"
|
||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||
|
@ -328,6 +328,10 @@ class Onion(object):
|
||||
f.write(self.settings.get("tor_bridges_use_custom_bridges"))
|
||||
f.write("\nUseBridges 1")
|
||||
|
||||
# Make sure the tor path is accurate
|
||||
if not os.path.exists(self.tor_path):
|
||||
raise BundledTorNotSupported(f"Cannot find tor binary: {self.tor_path}")
|
||||
|
||||
# Execute a tor subprocess
|
||||
start_ts = time.time()
|
||||
if self.common.platform == "Windows":
|
||||
|
Loading…
Reference in New Issue
Block a user