aboutsummaryrefslogtreecommitdiff
path: root/desktop/src/onionshare/gui_common.py
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2020-10-15 19:09:46 -0700
committerMicah Lee <micah@micahflee.com>2020-10-15 19:09:46 -0700
commit7ece466d823ed876589071b4f652c4e6f89b1483 (patch)
tree0cc9a99ca59a0bd3bac181d31c18ed1d48ee9576 /desktop/src/onionshare/gui_common.py
parent5b2fe2019cdcfa6cedb844b5796133d3776dcf47 (diff)
downloadonionshare-7ece466d823ed876589071b4f652c4e6f89b1483.tar.gz
onionshare-7ece466d823ed876589071b4f652c4e6f89b1483.zip
Put tor binaries in desktop app resources, not cli resources, and fix Windows packaging
Diffstat (limited to 'desktop/src/onionshare/gui_common.py')
-rw-r--r--desktop/src/onionshare/gui_common.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/desktop/src/onionshare/gui_common.py b/desktop/src/onionshare/gui_common.py
index 1de82b3d..56e86067 100644
--- a/desktop/src/onionshare/gui_common.py
+++ b/desktop/src/onionshare/gui_common.py
@@ -50,7 +50,7 @@ class GuiCommon:
strings.load_strings(self.common, self.get_resource_path("locale"))
# Start the Onion
- self.onion = Onion(common)
+ self.onion = Onion(common, get_tor_paths=self.get_tor_paths)
# Lock filename
self.lock_filename = os.path.join(self.common.build_data_dir(), "lock")
@@ -328,6 +328,44 @@ class GuiCommon:
font-style: italic;
}""",
}
+
+ 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":
+ 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")
+ 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 = 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.common.platform == "BSD":
+ tor_path = "/usr/local/bin/tor"
+ 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"
+
+ return (
+ tor_path,
+ tor_geo_ip_file_path,
+ tor_geo_ipv6_file_path,
+ obfs4proxy_file_path,
+ )
@staticmethod
def get_resource_path(filename):