mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Started to implement Bundled Tor connection settings
This commit is contained in:
parent
8280b1b5d8
commit
da225ed7d1
@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os, sys, time, argparse, shutil, socket, threading
|
||||
|
||||
from . import strings, helpers, web, onion
|
||||
from . import strings, helpers, web
|
||||
from .onion import *
|
||||
|
||||
class OnionShare(object):
|
||||
"""
|
||||
@ -84,7 +85,7 @@ class OnionShare(object):
|
||||
return
|
||||
|
||||
if not self.onion:
|
||||
self.onion = onion.Onion(self.stealth)
|
||||
self.onion = Onion(self.stealth)
|
||||
|
||||
self.onion_host = self.onion.start(self.port)
|
||||
|
||||
@ -155,7 +156,7 @@ def main(cwd=None):
|
||||
app = OnionShare(debug, local_only, stay_open, transparent_torification, stealth)
|
||||
app.choose_port()
|
||||
app.start_onion_service()
|
||||
except (onion.TorTooOld, onion.TorErrorInvalidSetting, onion.TorErrorAutomatic, onion.TorErrorSocketPort, onion.TorErrorSocketFile, onion.TorErrorMissingPassword, onion.TorErrorUnreadableCookieFile, onion.TorErrorAuthError, onion.TorErrorProtocolError) as e:
|
||||
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported) as e:
|
||||
sys.exit(e.args[0])
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
|
@ -87,6 +87,12 @@ class TorTooOld(Exception):
|
||||
"""
|
||||
pass
|
||||
|
||||
class BundledTorNotSupported(Exception):
|
||||
"""
|
||||
This exception is raised if onionshare is set to use the bundled Tor binary,
|
||||
but it's not supported on that platform, or in dev mode.
|
||||
"""
|
||||
|
||||
class Onion(object):
|
||||
"""
|
||||
Onion is an abstraction layer for connecting to the Tor control port and
|
||||
@ -107,6 +113,15 @@ class Onion(object):
|
||||
# Try to connect to Tor
|
||||
self.c = None
|
||||
|
||||
if self.settings.get('connection_type') == 'bundled':
|
||||
dev_mode = getattr(sys, 'onionshare_dev_mode', False)
|
||||
p = platform.system()
|
||||
|
||||
if (p != 'Windows' and p != 'Darwin') or dev_mode:
|
||||
raise BundledTorNotSupported(strings._('settings_error_bundled_tor_not_supported'))
|
||||
|
||||
# TODO: actually implement bundled Tor
|
||||
|
||||
if self.settings.get('connection_type') == 'automatic':
|
||||
# Automatically try to guess the right way to connect to Tor Browser
|
||||
p = platform.system()
|
||||
|
@ -22,7 +22,7 @@ import sys, platform
|
||||
|
||||
from onionshare import strings
|
||||
from onionshare.settings import Settings
|
||||
from onionshare.onion import Onion, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError
|
||||
from onionshare.onion import *
|
||||
|
||||
from .alert import Alert
|
||||
|
||||
@ -290,7 +290,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
# If an exception hasn't been raised yet, the Tor settings work
|
||||
Alert(strings._('settings_test_success', True).format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth))
|
||||
|
||||
except (TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError) as e:
|
||||
except (TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported) as e:
|
||||
Alert(e.args[0], QtWidgets.QMessageBox.Warning)
|
||||
|
||||
def save_clicked(self):
|
||||
|
@ -85,6 +85,7 @@
|
||||
"settings_error_auth": "Connected to {}:{}, but can't authenticate. Maybe this isn't a Tor controller?",
|
||||
"settings_error_missing_password": "Connected to Tor controller, but it requires a password to authenticate.",
|
||||
"settings_error_unreadable_cookie_file": "Connected to Tor controller, but can't authenticate because your password may be wrong, and your user doesn't have permission to read the cookie file.",
|
||||
"settings_error_bundled_tor_not_supported": "Bundled Tor is only supported in Windows and macOS. It's not supported when not using developer mode or the command line interface.",
|
||||
"settings_test_success": "Congratulations, OnionShare can connect to the Tor controller.\n\nTor version: {}\nSupports ephemeral onion services: {}\nSupports stealth onion services: {}",
|
||||
"error_tor_protocol_error": "Error talking to the Tor controller.\nIf you're using Whonix, check out https://www.whonix.org/wiki/onionshare to make OnionShare work."
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user