mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Make get_tor_paths work properly now that in linux the tor binaries are bundled too
This commit is contained in:
parent
343a8cccc1
commit
229da0aaab
@ -309,10 +309,21 @@ class Common:
|
||||
|
||||
def get_tor_paths(self):
|
||||
if self.platform == "Linux":
|
||||
# Look in resources first
|
||||
base_path = self.get_resource_path("tor")
|
||||
if os.path.exists(base_path):
|
||||
tor_path = os.path.join(base_path, "tor")
|
||||
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
|
||||
snowflake_file_path = os.path.join(base_path, "snowflake-client")
|
||||
else:
|
||||
# Fallback to looking in the path
|
||||
tor_path = shutil.which("tor")
|
||||
if not tor_path:
|
||||
raise CannotFindTor()
|
||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
||||
snowflake_file_path = shutil.which("snowflake-client")
|
||||
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")
|
||||
@ -320,13 +331,25 @@ class Common:
|
||||
base_path = self.get_resource_path("tor")
|
||||
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe")
|
||||
snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe")
|
||||
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":
|
||||
# Look in resources first
|
||||
base_path = self.get_resource_path("tor")
|
||||
if os.path.exists(base_path):
|
||||
tor_path = os.path.join(base_path, "tor")
|
||||
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
|
||||
snowflake_file_path = os.path.join(base_path, "snowflake-client")
|
||||
else:
|
||||
# Fallback to looking in the path
|
||||
tor_path = shutil.which("tor")
|
||||
if not tor_path:
|
||||
raise CannotFindTor()
|
||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
||||
snowflake_file_path = shutil.which("snowflake-client")
|
||||
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")
|
||||
@ -335,12 +358,14 @@ class Common:
|
||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
||||
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
||||
snowflake_file_path = "/usr/local/bin/snowflake-client"
|
||||
|
||||
return (
|
||||
tor_path,
|
||||
tor_geo_ip_file_path,
|
||||
tor_geo_ipv6_file_path,
|
||||
obfs4proxy_file_path,
|
||||
snowflake_file_path,
|
||||
)
|
||||
|
||||
def build_data_dir(self):
|
||||
|
@ -153,6 +153,7 @@ class Onion(object):
|
||||
self.tor_geo_ip_file_path,
|
||||
self.tor_geo_ipv6_file_path,
|
||||
self.obfs4proxy_file_path,
|
||||
self.snowflake_file_path,
|
||||
) = get_tor_paths()
|
||||
|
||||
# The tor process
|
||||
@ -178,10 +179,10 @@ class Onion(object):
|
||||
key_bytes = bytes(key)
|
||||
key_b32 = base64.b32encode(key_bytes)
|
||||
# strip trailing ====
|
||||
assert key_b32[-4:] == b'===='
|
||||
assert key_b32[-4:] == b"===="
|
||||
key_b32 = key_b32[:-4]
|
||||
# change from b'ASDF' to ASDF
|
||||
s = key_b32.decode('utf-8')
|
||||
s = key_b32.decode("utf-8")
|
||||
return s
|
||||
|
||||
def connect(
|
||||
@ -650,16 +651,24 @@ class Onion(object):
|
||||
)
|
||||
raise TorTooOldStealth()
|
||||
else:
|
||||
if key_type == "NEW" or not mode_settings.get("onion", "client_auth_priv_key"):
|
||||
if key_type == "NEW" or not mode_settings.get(
|
||||
"onion", "client_auth_priv_key"
|
||||
):
|
||||
# Generate a new key pair for Client Auth on new onions, or if
|
||||
# it's a persistent onion but for some reason we don't them
|
||||
client_auth_priv_key_raw = nacl.public.PrivateKey.generate()
|
||||
client_auth_priv_key = self.key_str(client_auth_priv_key_raw)
|
||||
client_auth_pub_key = self.key_str(client_auth_priv_key_raw.public_key)
|
||||
client_auth_pub_key = self.key_str(
|
||||
client_auth_priv_key_raw.public_key
|
||||
)
|
||||
else:
|
||||
# These should have been saved in settings from the previous run of a persistent onion
|
||||
client_auth_priv_key = mode_settings.get("onion", "client_auth_priv_key")
|
||||
client_auth_pub_key = mode_settings.get("onion", "client_auth_pub_key")
|
||||
client_auth_priv_key = mode_settings.get(
|
||||
"onion", "client_auth_priv_key"
|
||||
)
|
||||
client_auth_pub_key = mode_settings.get(
|
||||
"onion", "client_auth_pub_key"
|
||||
)
|
||||
|
||||
try:
|
||||
if not self.supports_stealth:
|
||||
|
@ -46,9 +46,12 @@ def main():
|
||||
)
|
||||
working_path = os.path.join(root_path, "build", "tor")
|
||||
tarball_path = os.path.join(working_path, tarball_filename)
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
|
||||
# Make sure dirs exist
|
||||
if not os.path.exists(working_path):
|
||||
os.makedirs(working_path, exist_ok=True)
|
||||
|
||||
# Make sure the dist path exists
|
||||
dist_path = os.path.join(working_path, "dist")
|
||||
if not os.path.exists(dist_path):
|
||||
os.makedirs(dist_path, exist_ok=True)
|
||||
|
||||
|
@ -38,6 +38,7 @@ def main():
|
||||
# Reinstall the new wheel
|
||||
subprocess.call(["pip", "uninstall", "onionshare-cli", "-y"])
|
||||
subprocess.call(["pip", "install", os.path.join(desktop_path, wheel_basename)])
|
||||
subprocess.call(["pip", "install", "typing-extensions"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -415,21 +415,20 @@ class GuiCommon:
|
||||
|
||||
def get_tor_paths(self):
|
||||
if self.common.platform == "Linux":
|
||||
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")
|
||||
elif self.common.platform == "Windows":
|
||||
return self.common.get_tor_paths()
|
||||
|
||||
if self.common.platform == "Windows":
|
||||
base_path = self.get_resource_path("tor")
|
||||
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe")
|
||||
snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe")
|
||||
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.common.platform == "Darwin":
|
||||
base_path = self.get_resource_path("tor")
|
||||
tor_path = os.path.join(base_path, "tor")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
|
||||
snowflake_file_path = os.path.join(base_path, "snowflake-client")
|
||||
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||
elif self.common.platform == "BSD":
|
||||
@ -437,12 +436,14 @@ class GuiCommon:
|
||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
||||
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
||||
snowflake_file_path = "/usr/local/bin/snowflake-client"
|
||||
|
||||
return (
|
||||
tor_path,
|
||||
tor_geo_ip_file_path,
|
||||
tor_geo_ipv6_file_path,
|
||||
obfs4proxy_file_path,
|
||||
snowflake_file_path,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user