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,38 +309,63 @@ class Common:
|
|||||||
|
|
||||||
def get_tor_paths(self):
|
def get_tor_paths(self):
|
||||||
if self.platform == "Linux":
|
if self.platform == "Linux":
|
||||||
tor_path = shutil.which("tor")
|
# Look in resources first
|
||||||
if not tor_path:
|
base_path = self.get_resource_path("tor")
|
||||||
raise CannotFindTor()
|
if os.path.exists(base_path):
|
||||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
tor_path = os.path.join(base_path, "tor")
|
||||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||||
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||||
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/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")
|
||||||
elif self.platform == "Windows":
|
elif self.platform == "Windows":
|
||||||
base_path = self.get_resource_path("tor")
|
base_path = self.get_resource_path("tor")
|
||||||
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
||||||
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.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_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
||||||
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
||||||
elif self.platform == "Darwin":
|
elif self.platform == "Darwin":
|
||||||
tor_path = shutil.which("tor")
|
# Look in resources first
|
||||||
if not tor_path:
|
base_path = self.get_resource_path("tor")
|
||||||
raise CannotFindTor()
|
if os.path.exists(base_path):
|
||||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
tor_path = os.path.join(base_path, "tor")
|
||||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||||
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||||
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/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")
|
||||||
elif self.platform == "BSD":
|
elif self.platform == "BSD":
|
||||||
tor_path = "/usr/local/bin/tor"
|
tor_path = "/usr/local/bin/tor"
|
||||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||||
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
||||||
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
||||||
|
snowflake_file_path = "/usr/local/bin/snowflake-client"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
tor_path,
|
tor_path,
|
||||||
tor_geo_ip_file_path,
|
tor_geo_ip_file_path,
|
||||||
tor_geo_ipv6_file_path,
|
tor_geo_ipv6_file_path,
|
||||||
obfs4proxy_file_path,
|
obfs4proxy_file_path,
|
||||||
|
snowflake_file_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
def build_data_dir(self):
|
def build_data_dir(self):
|
||||||
|
@ -153,6 +153,7 @@ class Onion(object):
|
|||||||
self.tor_geo_ip_file_path,
|
self.tor_geo_ip_file_path,
|
||||||
self.tor_geo_ipv6_file_path,
|
self.tor_geo_ipv6_file_path,
|
||||||
self.obfs4proxy_file_path,
|
self.obfs4proxy_file_path,
|
||||||
|
self.snowflake_file_path,
|
||||||
) = get_tor_paths()
|
) = get_tor_paths()
|
||||||
|
|
||||||
# The tor process
|
# The tor process
|
||||||
@ -178,10 +179,10 @@ class Onion(object):
|
|||||||
key_bytes = bytes(key)
|
key_bytes = bytes(key)
|
||||||
key_b32 = base64.b32encode(key_bytes)
|
key_b32 = base64.b32encode(key_bytes)
|
||||||
# strip trailing ====
|
# strip trailing ====
|
||||||
assert key_b32[-4:] == b'===='
|
assert key_b32[-4:] == b"===="
|
||||||
key_b32 = key_b32[:-4]
|
key_b32 = key_b32[:-4]
|
||||||
# change from b'ASDF' to ASDF
|
# change from b'ASDF' to ASDF
|
||||||
s = key_b32.decode('utf-8')
|
s = key_b32.decode("utf-8")
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def connect(
|
def connect(
|
||||||
@ -650,16 +651,24 @@ class Onion(object):
|
|||||||
)
|
)
|
||||||
raise TorTooOldStealth()
|
raise TorTooOldStealth()
|
||||||
else:
|
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
|
# 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
|
# 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_raw = nacl.public.PrivateKey.generate()
|
||||||
client_auth_priv_key = self.key_str(client_auth_priv_key_raw)
|
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:
|
else:
|
||||||
# These should have been saved in settings from the previous run of a persistent onion
|
# 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_priv_key = mode_settings.get(
|
||||||
client_auth_pub_key = mode_settings.get("onion", "client_auth_pub_key")
|
"onion", "client_auth_priv_key"
|
||||||
|
)
|
||||||
|
client_auth_pub_key = mode_settings.get(
|
||||||
|
"onion", "client_auth_pub_key"
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not self.supports_stealth:
|
if not self.supports_stealth:
|
||||||
|
@ -46,9 +46,12 @@ def main():
|
|||||||
)
|
)
|
||||||
working_path = os.path.join(root_path, "build", "tor")
|
working_path = os.path.join(root_path, "build", "tor")
|
||||||
tarball_path = os.path.join(working_path, tarball_filename)
|
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):
|
if not os.path.exists(dist_path):
|
||||||
os.makedirs(dist_path, exist_ok=True)
|
os.makedirs(dist_path, exist_ok=True)
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ def main():
|
|||||||
# Reinstall the new wheel
|
# Reinstall the new wheel
|
||||||
subprocess.call(["pip", "uninstall", "onionshare-cli", "-y"])
|
subprocess.call(["pip", "uninstall", "onionshare-cli", "-y"])
|
||||||
subprocess.call(["pip", "install", os.path.join(desktop_path, wheel_basename)])
|
subprocess.call(["pip", "install", os.path.join(desktop_path, wheel_basename)])
|
||||||
|
subprocess.call(["pip", "install", "typing-extensions"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -205,14 +205,14 @@ class GuiCommon:
|
|||||||
"downloads_uploads_not_empty": """
|
"downloads_uploads_not_empty": """
|
||||||
QWidget{
|
QWidget{
|
||||||
background-color: """
|
background-color: """
|
||||||
+ history_background_color
|
+ history_background_color
|
||||||
+""";
|
+ """;
|
||||||
}""",
|
}""",
|
||||||
"downloads_uploads_empty": """
|
"downloads_uploads_empty": """
|
||||||
QWidget {
|
QWidget {
|
||||||
background-color: """
|
background-color: """
|
||||||
+ history_background_color
|
+ history_background_color
|
||||||
+""";
|
+ """;
|
||||||
border: 1px solid #999999;
|
border: 1px solid #999999;
|
||||||
}
|
}
|
||||||
QWidget QLabel {
|
QWidget QLabel {
|
||||||
@ -263,7 +263,7 @@ class GuiCommon:
|
|||||||
+ """;
|
+ """;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
}""",
|
}""",
|
||||||
"history_default_label" : """
|
"history_default_label": """
|
||||||
QLabel {
|
QLabel {
|
||||||
color: """
|
color: """
|
||||||
+ history_label_color
|
+ history_label_color
|
||||||
@ -415,21 +415,20 @@ class GuiCommon:
|
|||||||
|
|
||||||
def get_tor_paths(self):
|
def get_tor_paths(self):
|
||||||
if self.common.platform == "Linux":
|
if self.common.platform == "Linux":
|
||||||
tor_path = shutil.which("tor")
|
return self.common.get_tor_paths()
|
||||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
|
||||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
if self.common.platform == "Windows":
|
||||||
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":
|
|
||||||
base_path = self.get_resource_path("tor")
|
base_path = self.get_resource_path("tor")
|
||||||
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
||||||
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.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_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
||||||
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
||||||
elif self.common.platform == "Darwin":
|
elif self.common.platform == "Darwin":
|
||||||
base_path = self.get_resource_path("tor")
|
base_path = self.get_resource_path("tor")
|
||||||
tor_path = os.path.join(base_path, "tor")
|
tor_path = os.path.join(base_path, "tor")
|
||||||
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy")
|
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_ip_file_path = os.path.join(base_path, "geoip")
|
||||||
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||||
elif self.common.platform == "BSD":
|
elif self.common.platform == "BSD":
|
||||||
@ -437,12 +436,14 @@ class GuiCommon:
|
|||||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||||
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
||||||
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
||||||
|
snowflake_file_path = "/usr/local/bin/snowflake-client"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
tor_path,
|
tor_path,
|
||||||
tor_geo_ip_file_path,
|
tor_geo_ip_file_path,
|
||||||
tor_geo_ipv6_file_path,
|
tor_geo_ipv6_file_path,
|
||||||
obfs4proxy_file_path,
|
obfs4proxy_file_path,
|
||||||
|
snowflake_file_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user