mirror of
https://github.com/onionshare/onionshare.git
synced 2025-05-02 06:26:10 -04:00
Merge branch 'cx_freeze-packaging' into develop
This commit is contained in:
commit
0dccb55127
182 changed files with 2813 additions and 1010 deletions
|
@ -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"
|
||||
|
|
|
@ -414,6 +414,10 @@ class Onion(object):
|
|||
self.common.log("Onion", "connect", f"tor pid: {self.tor_proc.pid}")
|
||||
time.sleep(2)
|
||||
|
||||
return_code = self.tor_proc.poll()
|
||||
if return_code != None:
|
||||
self.common.log("Onion", "connect", f"tor process has terminated early: {return_code}")
|
||||
|
||||
# Connect to the controller
|
||||
self.common.log("Onion", "connect", "authenticating to tor controller")
|
||||
try:
|
||||
|
|
|
@ -189,7 +189,7 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
# and serve that
|
||||
use_gzip = self.should_use_gzip()
|
||||
if use_gzip:
|
||||
file_to_download = self.gzip_file.name
|
||||
file_to_download = self.gzip_filename
|
||||
self.filesize = self.gzip_filesize
|
||||
etag = self.gzip_etag
|
||||
else:
|
||||
|
@ -492,20 +492,21 @@ class ShareModeWeb(SendBaseModeWeb):
|
|||
self.download_etag = make_etag(f)
|
||||
|
||||
# Compress the file with gzip now, so we don't have to do it on each request
|
||||
self.gzip_file = tempfile.NamedTemporaryFile(
|
||||
"wb+", dir=self.common.build_tmp_dir()
|
||||
self.gzip_tmp_dir = tempfile.TemporaryDirectory(
|
||||
dir=self.common.build_tmp_dir()
|
||||
)
|
||||
self.gzip_filename = os.path.join(self.gzip_tmp_dir.name, "file.gz")
|
||||
self._gzip_compress(
|
||||
self.download_filename, self.gzip_file.name, 6, processed_size_callback
|
||||
self.download_filename, self.gzip_filename, 6, processed_size_callback
|
||||
)
|
||||
self.gzip_filesize = os.path.getsize(self.gzip_file.name)
|
||||
with open(self.gzip_file.name, "rb") as f:
|
||||
self.gzip_filesize = os.path.getsize(self.gzip_filename)
|
||||
with open(self.gzip_filename, "rb") as f:
|
||||
self.gzip_etag = make_etag(f)
|
||||
|
||||
self.is_zipped = False
|
||||
|
||||
# Cleanup this tempfile
|
||||
self.web.cleanup_tempfiles.append(self.gzip_file)
|
||||
self.web.cleanup_tempdirs.append(self.gzip_tmp_dir)
|
||||
|
||||
else:
|
||||
# Zip up the files and folders
|
||||
|
|
|
@ -89,7 +89,7 @@ class Web:
|
|||
#
|
||||
# It's probably #notourbug but we can fix it by forcing the mimetype.
|
||||
# https://github.com/onionshare/onionshare/issues/1443
|
||||
mimetypes.add_type('text/javascript', '.js')
|
||||
mimetypes.add_type("text/javascript", ".js")
|
||||
|
||||
# The flask app
|
||||
self.app = Flask(
|
||||
|
@ -162,7 +162,12 @@ class Web:
|
|||
elif self.mode == "website":
|
||||
self.website_mode = WebsiteModeWeb(self.common, self)
|
||||
elif self.mode == "chat":
|
||||
self.socketio = SocketIO()
|
||||
if self.common.verbose:
|
||||
self.socketio = SocketIO(
|
||||
async_mode="gevent", logger=True, engineio_logger=True
|
||||
)
|
||||
else:
|
||||
self.socketio = SocketIO(async_mode="gevent")
|
||||
self.socketio.init_app(self.app)
|
||||
self.chat_mode = ChatModeWeb(self.common, self)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue