diff options
author | Micah Lee <micah@micahflee.com> | 2022-02-13 11:28:16 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2022-02-13 11:28:16 -0800 |
commit | e168080b77c1ec7ba40022a106a43d524e227945 (patch) | |
tree | bdbd8ae8be5dc3eb4d9ca1a945a55f537f8ced18 /cli/onionshare_cli/common.py | |
parent | d7269e80f7a7e82ab120e2b966ff413d95db5e47 (diff) | |
parent | 1ca017d5ade6f8bd16b4e9f153e67e29c35a5e1d (diff) | |
download | onionshare-e168080b77c1ec7ba40022a106a43d524e227945.tar.gz onionshare-e168080b77c1ec7ba40022a106a43d524e227945.zip |
Merge branch 'develop' into censorship
Diffstat (limited to 'cli/onionshare_cli/common.py')
-rw-r--r-- | cli/onionshare_cli/common.py | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/cli/onionshare_cli/common.py b/cli/onionshare_cli/common.py index 3d918fa0..ceec654d 100644 --- a/cli/onionshare_cli/common.py +++ b/cli/onionshare_cli/common.py @@ -2,7 +2,7 @@ """ OnionShare | https://onionshare.org/ -Copyright (C) 2014-2021 Micah Lee, et al. <micah@micahflee.com> +Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -329,23 +329,49 @@ class Common: 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": + # In Windows, the Tor binaries are in the onionshare package, not the onionshare_cli package base_path = self.get_resource_path("tor") + base_path = base_path.replace("onionshare_cli", "onionshare") tor_path = os.path.join(base_path, "Tor", "tor.exe") + + # If tor.exe isn't there, mayber we're running from the source tree + if not os.path.exists(tor_path): + base_path = os.path.join(os.getcwd(), "onionshare", "resources", "tor") + + tor_path = os.path.join(base_path, "Tor", "tor.exe") + if not os.path.exists(tor_path): + raise CannotFindTor() + obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe") snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe") meek_client_file_path = os.path.join(base_path, "Tor", "meek-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": - tor_path = shutil.which("tor") - if not tor_path: - raise CannotFindTor() - obfs4proxy_file_path = shutil.which("obfs4proxy") - snowflake_file_path = shutil.which("snowflake-client") - meek_client_file_path = shutil.which("meek-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") + # Let's see if we have tor binaries in the onionshare GUI package + base_path = self.get_resource_path("tor") + base_path = base_path.replace("onionshare_cli", "onionshare") + tor_path = os.path.join(base_path, "tor") + if os.path.exists(tor_path): + obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy") + snowflake_file_path = os.path.join(base_path, "snowflake-client") + meek_client_file_path = os.path.join(base_path, "meek-client") + tor_geo_ip_file_path = os.path.join(base_path, "geoip") + tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6") + else: + # Fallback to looking in the path + tor_path = shutil.which("tor") + if not os.path.exists(tor_path): + raise CannotFindTor() + + obfs4proxy_file_path = shutil.which("obfs4proxy") + snowflake_file_path = shutil.which("snowflake-client") + meek_client_file_path = shutil.which("meek-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": tor_path = "/usr/local/bin/tor" tor_geo_ip_file_path = "/usr/local/share/tor/geoip" |