Guess the default socket file path for new versions of Tor Browser in OS X

This commit is contained in:
Micah Lee 2017-01-06 11:46:41 -08:00
parent 406fffdb39
commit d069cc2a29
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -108,6 +108,7 @@ class Onion(object):
if self.settings.get('connection_type') == 'automatic': if self.settings.get('connection_type') == 'automatic':
# Automatically try to guess the right way to connect to Tor Browser # Automatically try to guess the right way to connect to Tor Browser
p = platform.system()
# Try connecting to control port # Try connecting to control port
found_tor = False found_tor = False
@ -131,11 +132,19 @@ class Onion(object):
except: except:
pass pass
# If this still didn't work, try guessing the default socket file path
socket_file_path = ''
if not found_tor:
if p == 'Darwin':
socket_file_path = os.path.expanduser('~/Library/Application Support/TorBrowser-Data/Tor/control.socket')
self.c = Controller.from_socket_file(path=socket_file_path)
found_tor = True
# If connecting to default control ports failed, so let's try # If connecting to default control ports failed, so let's try
# guessing the socket file name next # guessing the socket file name next
if not found_tor: if not found_tor:
try: try:
p = platform.system()
if p == 'Linux': if p == 'Linux':
socket_file_path = '/run/user/{}/Tor/control.socket'.format(os.geteuid()) socket_file_path = '/run/user/{}/Tor/control.socket'.format(os.geteuid())
elif p == 'Darwin': elif p == 'Darwin':