Require tor 0.4.0.0 for v3 onion services (will change in the future). And update settings dialog so if the connected version of tor doesn't support v3 onions, then always show legacy options. If it does support v3 onions, allow 'Use legacy addresses'

This commit is contained in:
Micah Lee 2018-12-05 20:33:45 -08:00
parent aadb2a01f0
commit 1d1efb7e54
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 25 additions and 11 deletions

View File

@ -387,6 +387,7 @@ class Onion(object):
# Get the tor version # Get the tor version
self.tor_version = self.c.get_version().version_str self.tor_version = self.c.get_version().version_str
self.common.log('Onion', 'connect', 'Connected to tor {}'.format(self.tor_version))
# Do the versions of stem and tor that I'm using support ephemeral onion services? # Do the versions of stem and tor that I'm using support ephemeral onion services?
list_ephemeral_hidden_services = getattr(self.c, "list_ephemeral_hidden_services", None) list_ephemeral_hidden_services = getattr(self.c, "list_ephemeral_hidden_services", None)
@ -403,7 +404,9 @@ class Onion(object):
self.supports_stealth = False self.supports_stealth = False
# Does this version of Tor support next-gen ('v3') onions? # Does this version of Tor support next-gen ('v3') onions?
self.supports_next_gen_onions = self.tor_version > Version('0.3.3.1') # Note, this is the version of Tor where this bug was fixed:
# https://trac.torproject.org/projects/tor/ticket/28619
self.supports_v3_onions = self.tor_version > Version('0.4.0.0')
def is_authenticated(self): def is_authenticated(self):
""" """

View File

@ -164,15 +164,6 @@ class SettingsDialog(QtWidgets.QDialog):
onion_settings_widget = QtWidgets.QWidget() onion_settings_widget = QtWidgets.QWidget()
onion_settings_widget.setLayout(onion_settings_layout) onion_settings_widget.setLayout(onion_settings_layout)
# If we're connected to Tor, show onion service settings, show label if not
if self.onion.is_authenticated():
connect_to_tor_label.hide()
onion_settings_widget.show()
else:
connect_to_tor_label.show()
onion_settings_widget.hide()
# General options layout # General options layout
general_group_layout = QtWidgets.QVBoxLayout() general_group_layout = QtWidgets.QVBoxLayout()
general_group_layout.addWidget(self.public_mode_widget) general_group_layout.addWidget(self.public_mode_widget)
@ -480,6 +471,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.setLayout(layout) self.setLayout(layout)
self.cancel_button.setFocus() self.cancel_button.setFocus()
# Load settings, and fill them in # Load settings, and fill them in
self.old_settings = Settings(self.common, self.config) self.old_settings = Settings(self.common, self.config)
self.old_settings.load() self.old_settings.load()
@ -599,6 +591,25 @@ class SettingsDialog(QtWidgets.QDialog):
new_bridges = ''.join(new_bridges) new_bridges = ''.join(new_bridges)
self.tor_bridges_use_custom_textbox.setPlainText(new_bridges) self.tor_bridges_use_custom_textbox.setPlainText(new_bridges)
# If we're connected to Tor, show onion service settings, show label if not
if self.onion.is_authenticated():
connect_to_tor_label.hide()
onion_settings_widget.show()
# If v3 onion services are supported, allow using legacy mode
if self.onion.supports_v3_onions:
self.common.log('SettingsDialog', '__init__', 'v3 onions are supported')
self.use_legacy_v2_onions_checkbox.show()
else:
self.common.log('SettingsDialog', '__init__', 'v3 onions are not supported')
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
self.use_legacy_v2_onions_widget.hide()
self.use_legacy_v2_onions_checkbox_clicked(True)
else:
connect_to_tor_label.show()
onion_settings_widget.hide()
def connection_type_bundled_toggled(self, checked): def connection_type_bundled_toggled(self, checked):
""" """
Connection type bundled was toggled. If checked, hide authentication fields. Connection type bundled was toggled. If checked, hide authentication fields.
@ -774,7 +785,7 @@ class SettingsDialog(QtWidgets.QDialog):
onion.connect(custom_settings=settings, config=self.config, tor_status_update_func=tor_status_update_func) onion.connect(custom_settings=settings, config=self.config, tor_status_update_func=tor_status_update_func)
# If an exception hasn't been raised yet, the Tor settings work # If an exception hasn't been raised yet, the Tor settings work
Alert(self.common, strings._('settings_test_success').format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth, onion.supports_next_gen_onions)) Alert(self.common, strings._('settings_test_success').format(onion.tor_version, onion.supports_ephemeral, onion.supports_stealth, onion.supports_v3_onions))
# Clean up # Clean up
onion.cleanup() onion.cleanup()