mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-10 03:37:28 -03:00
Fix bug that was preventing tor from connecting in snapcraft
This commit is contained in:
parent
f09bb66425
commit
99c85f55e2
2 changed files with 27 additions and 11 deletions
|
@ -437,6 +437,12 @@ class Common:
|
||||||
Returns True if OnionShare is running in a Flatpak sandbox
|
Returns True if OnionShare is running in a Flatpak sandbox
|
||||||
"""
|
"""
|
||||||
return os.environ.get("FLATPAK_ID") == "org.onionshare.OnionShare"
|
return os.environ.get("FLATPAK_ID") == "org.onionshare.OnionShare"
|
||||||
|
|
||||||
|
def is_snapcraft(self):
|
||||||
|
"""
|
||||||
|
Returns True if OnionShare is running in a Flatpak sandbox
|
||||||
|
"""
|
||||||
|
return os.environ.get("SNAP_INSTANCE_NAME") == "onionshare"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def random_string(num_bytes, output_len=None):
|
def random_string(num_bytes, output_len=None):
|
||||||
|
|
|
@ -29,6 +29,7 @@ import subprocess
|
||||||
import time
|
import time
|
||||||
import shlex
|
import shlex
|
||||||
import psutil
|
import psutil
|
||||||
|
import traceback
|
||||||
|
|
||||||
from distutils.version import LooseVersion as Version
|
from distutils.version import LooseVersion as Version
|
||||||
|
|
||||||
|
@ -371,11 +372,16 @@ class Onion(object):
|
||||||
startupinfo=startupinfo,
|
startupinfo=startupinfo,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
if self.common.is_snapcraft():
|
||||||
|
env = None
|
||||||
|
else:
|
||||||
|
env = {"LD_LIBRARY_PATH": os.path.dirname(self.tor_path)}
|
||||||
|
|
||||||
self.tor_proc = subprocess.Popen(
|
self.tor_proc = subprocess.Popen(
|
||||||
[self.tor_path, "-f", self.tor_torrc],
|
[self.tor_path, "-f", self.tor_torrc],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
env={"LD_LIBRARY_PATH": os.path.dirname(self.tor_path)},
|
env=env,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Wait for the tor controller to start
|
# Wait for the tor controller to start
|
||||||
|
@ -392,16 +398,20 @@ class Onion(object):
|
||||||
"connect",
|
"connect",
|
||||||
"authenticating to tor controller",
|
"authenticating to tor controller",
|
||||||
)
|
)
|
||||||
# try:
|
try:
|
||||||
if self.common.platform == "Windows" or self.common.platform == "Darwin":
|
if (
|
||||||
self.c = Controller.from_port(port=self.tor_control_port)
|
self.common.platform == "Windows"
|
||||||
self.c.authenticate()
|
or self.common.platform == "Darwin"
|
||||||
else:
|
):
|
||||||
self.c = Controller.from_socket_file(path=self.tor_control_socket)
|
self.c = Controller.from_port(port=self.tor_control_port)
|
||||||
self.c.authenticate()
|
self.c.authenticate()
|
||||||
# except Exception as e:
|
else:
|
||||||
# print("OnionShare could not connect to Tor:\n{}".format(e))
|
self.c = Controller.from_socket_file(path=self.tor_control_socket)
|
||||||
# raise BundledTorBroken(e.args[0])
|
self.c.authenticate()
|
||||||
|
except Exception as e:
|
||||||
|
print("OnionShare could not connect to Tor:\n{}".format(e.args[0]))
|
||||||
|
print(traceback.format_exc())
|
||||||
|
raise BundledTorBroken(e.args[0])
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue