diff options
author | Micah Lee <micah@micahflee.com> | 2018-01-17 16:19:30 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2018-01-17 16:19:30 -0800 |
commit | 713e45084a6bc71ec8b0dec3f98fbb681f831224 (patch) | |
tree | d8b56faa502fc802d608ae1005442d24ab9fbadf /onionshare | |
parent | ec6adfdb8f915b571dc3622ff86201e4032086f3 (diff) | |
parent | fc2dcafafc7d6d513c24e8aeb90b42e3d6712817 (diff) | |
download | onionshare-713e45084a6bc71ec8b0dec3f98fbb681f831224.tar.gz onionshare-713e45084a6bc71ec8b0dec3f98fbb681f831224.zip |
Merge branch '435_support_bridges' of https://github.com/mig5/onionshare into mig5-435_support_bridges
Diffstat (limited to 'onionshare')
-rw-r--r-- | onionshare/common.py | 8 | ||||
-rw-r--r-- | onionshare/onion.py | 21 | ||||
-rw-r--r-- | onionshare/settings.py | 3 |
3 files changed, 27 insertions, 5 deletions
diff --git a/onionshare/common.py b/onionshare/common.py index 562c71f2..25b901ee 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -94,9 +94,11 @@ def get_tor_paths(): tor_path = '/usr/bin/tor' tor_geo_ip_file_path = '/usr/share/tor/geoip' tor_geo_ipv6_file_path = '/usr/share/tor/geoip6' + obfs4proxy_file_path = '/usr/bin/obfs4proxy' elif p == 'Windows': base_path = os.path.join(os.path.dirname(os.path.dirname(get_resource_path(''))), 'tor') - tor_path = os.path.join(os.path.join(base_path, 'Tor'), "tor.exe") + tor_path = os.path.join(os.path.join(base_path, 'Tor'), 'tor.exe') + obfs4proxy_file_path = os.path.join(os.path.join(base_path, 'Tor'), 'obfs4proxy.exe') tor_geo_ip_file_path = os.path.join(os.path.join(os.path.join(base_path, 'Data'), 'Tor'), 'geoip') tor_geo_ipv6_file_path = os.path.join(os.path.join(os.path.join(base_path, 'Data'), 'Tor'), 'geoip6') elif p == 'Darwin': @@ -104,12 +106,14 @@ def get_tor_paths(): 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 p == 'OpenBSD' or p == 'FreeBSD': 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) + return (tor_path, tor_geo_ip_file_path, tor_geo_ipv6_file_path, obfs4proxy_file_path) def get_version(): diff --git a/onionshare/onion.py b/onionshare/onion.py index db1dfeaf..013a9177 100644 --- a/onionshare/onion.py +++ b/onionshare/onion.py @@ -140,7 +140,7 @@ class Onion(object): self.bundle_tor_supported = True # Set the path of the tor binary, for bundled tor - (self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path) = common.get_tor_paths() + (self.tor_path, self.tor_geo_ip_file_path, self.tor_geo_ipv6_file_path, self.obfs4proxy_file_path) = common.get_tor_paths() # The tor process self.tor_proc = None @@ -205,6 +205,16 @@ class Onion(object): with open(self.tor_torrc, 'w') as f: f.write(torrc_template) + # Bridge support + if self.settings.get('tor_bridges_use_obfs4'): + f.write('ClientTransportPlugin obfs4 exec {}\n'.format(self.obfs4proxy_file_path)) + with open(common.get_resource_path('torrc_template-obfs4')) as o: + for line in o: + f.write(line) + if self.settings.get('tor_bridges_use_custom_bridges'): + f.write(self.settings.get('tor_bridges_use_custom_bridges')) + f.write('\nUseBridges 1') + # Execute a tor subprocess start_ts = time.time() if self.system == 'Windows': @@ -254,8 +264,13 @@ class Onion(object): break time.sleep(0.2) - # Timeout after 90 seconds - if time.time() - start_ts > 90: + # If using bridges, it might take a bit longer to connect to Tor + if self.settings.get('tor_bridges_use_custom_bridges') or self.settings.get('tor_bridges_use_obfs4'): + connect_timeout = 150 + else: + # Timeout after 120 seconds + connect_timeout = 120 + if time.time() - start_ts > connect_timeout: print("") self.tor_proc.terminate() raise BundledTorTimeout(strings._('settings_error_bundled_tor_timeout')) diff --git a/onionshare/settings.py b/onionshare/settings.py index e8103757..94b5dde5 100644 --- a/onionshare/settings.py +++ b/onionshare/settings.py @@ -61,6 +61,9 @@ class Settings(object): 'use_stealth': False, 'use_autoupdate': True, 'autoupdate_timestamp': None, + 'no_bridges': True, + 'tor_bridges_use_obfs4': False, + 'tor_bridges_use_custom_bridges': '', 'save_private_key': False, 'private_key': '', 'slug': '', |