mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-27 14:57:25 -05:00
Support persistent v3 onions
This commit is contained in:
parent
181fed1a4a
commit
7c71aef15b
@ -451,20 +451,9 @@ class Onion(object):
|
|||||||
key_content = self.settings.get('private_key')
|
key_content = self.settings.get('private_key')
|
||||||
if self.is_v2_key(key_content):
|
if self.is_v2_key(key_content):
|
||||||
key_type = "RSA1024"
|
key_type = "RSA1024"
|
||||||
# The below section is commented out because re-publishing
|
|
||||||
# a pre-prepared v3 private key is currently unstable in Tor.
|
|
||||||
# This is fixed upstream but won't reach stable until 0.3.5
|
|
||||||
# (expected in December 2018)
|
|
||||||
# See https://trac.torproject.org/projects/tor/ticket/25552
|
|
||||||
# Until then, we will deliberately not work with 'persistent'
|
|
||||||
# v3 onions, which should not be possible via the GUI settings
|
|
||||||
# anyway.
|
|
||||||
# Our ticket: https://github.com/micahflee/onionshare/issues/677
|
|
||||||
#
|
|
||||||
# Assume it was a v3 key
|
|
||||||
# key_type = "ED25519-V3"
|
|
||||||
else:
|
else:
|
||||||
raise TorErrorProtocolError(strings._('error_invalid_private_key'))
|
# Assume it was a v3 key. Stem will throw an error if it's something illegible
|
||||||
|
key_type = "ED25519-V3"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
key_type = "NEW"
|
key_type = "NEW"
|
||||||
|
@ -122,7 +122,6 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
self.save_private_key_checkbox = QtWidgets.QCheckBox()
|
self.save_private_key_checkbox = QtWidgets.QCheckBox()
|
||||||
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.save_private_key_checkbox.setText(strings._("gui_save_private_key_checkbox"))
|
self.save_private_key_checkbox.setText(strings._("gui_save_private_key_checkbox"))
|
||||||
self.save_private_key_checkbox.clicked.connect(self.save_private_key_checkbox_clicked)
|
|
||||||
save_private_key_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL"))
|
save_private_key_label = QtWidgets.QLabel(strings._("gui_settings_whats_this").format("https://github.com/micahflee/onionshare/wiki/Using-a-Persistent-URL"))
|
||||||
save_private_key_label.setStyleSheet(self.common.css['settings_whats_this'])
|
save_private_key_label.setStyleSheet(self.common.css['settings_whats_this'])
|
||||||
save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
|
save_private_key_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
|
||||||
@ -498,22 +497,17 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
use_legacy_v2_onions = self.old_settings.get('use_legacy_v2_onions')
|
use_legacy_v2_onions = self.old_settings.get('use_legacy_v2_onions')
|
||||||
|
|
||||||
if use_legacy_v2_onions:
|
if use_legacy_v2_onions:
|
||||||
self.save_private_key_widget.show()
|
|
||||||
self.use_stealth_widget.show()
|
self.use_stealth_widget.show()
|
||||||
else:
|
else:
|
||||||
self.save_private_key_widget.hide()
|
|
||||||
self.use_stealth_widget.hide()
|
self.use_stealth_widget.hide()
|
||||||
|
|
||||||
save_private_key = self.old_settings.get('save_private_key')
|
save_private_key = self.old_settings.get('save_private_key')
|
||||||
if save_private_key:
|
if save_private_key:
|
||||||
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Checked)
|
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||||
# Legacy v2 mode is forced on if persistence is enabled
|
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(False)
|
|
||||||
else:
|
else:
|
||||||
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.save_private_key_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(True)
|
|
||||||
|
|
||||||
if use_legacy_v2_onions or save_private_key:
|
if use_legacy_v2_onions:
|
||||||
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
|
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||||
|
|
||||||
data_dir = self.old_settings.get('data_dir')
|
data_dir = self.old_settings.get('data_dir')
|
||||||
@ -535,8 +529,6 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
self.hidservauth_copy_button.show()
|
self.hidservauth_copy_button.show()
|
||||||
else:
|
else:
|
||||||
self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked)
|
||||||
if not save_private_key:
|
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(True)
|
|
||||||
|
|
||||||
use_autoupdate = self.old_settings.get('use_autoupdate')
|
use_autoupdate = self.old_settings.get('use_autoupdate')
|
||||||
if use_autoupdate:
|
if use_autoupdate:
|
||||||
@ -727,23 +719,10 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
Show the legacy settings if the legacy mode is enabled.
|
Show the legacy settings if the legacy mode is enabled.
|
||||||
"""
|
"""
|
||||||
if checked:
|
if checked:
|
||||||
self.save_private_key_widget.show()
|
|
||||||
self.use_stealth_widget.show()
|
self.use_stealth_widget.show()
|
||||||
else:
|
else:
|
||||||
self.save_private_key_widget.hide()
|
|
||||||
self.use_stealth_widget.hide()
|
self.use_stealth_widget.hide()
|
||||||
|
|
||||||
def save_private_key_checkbox_clicked(self, checked):
|
|
||||||
"""
|
|
||||||
Prevent the v2 legacy mode being switched off if persistence is enabled
|
|
||||||
"""
|
|
||||||
if checked:
|
|
||||||
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
|
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(False)
|
|
||||||
else:
|
|
||||||
if not self.stealth_checkbox.isChecked():
|
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(True)
|
|
||||||
|
|
||||||
def stealth_checkbox_clicked_connect(self, checked):
|
def stealth_checkbox_clicked_connect(self, checked):
|
||||||
"""
|
"""
|
||||||
Prevent the v2 legacy mode being switched off if stealth is enabled
|
Prevent the v2 legacy mode being switched off if stealth is enabled
|
||||||
@ -752,8 +731,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
|
self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Checked)
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(False)
|
self.use_legacy_v2_onions_checkbox.setEnabled(False)
|
||||||
else:
|
else:
|
||||||
if not self.save_private_key_checkbox.isChecked():
|
self.use_legacy_v2_onions_checkbox.setEnabled(True)
|
||||||
self.use_legacy_v2_onions_checkbox.setEnabled(True)
|
|
||||||
|
|
||||||
def data_dir_button_clicked(self):
|
def data_dir_button_clicked(self):
|
||||||
"""
|
"""
|
||||||
@ -965,8 +943,6 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
use_legacy_v2_onions = False
|
use_legacy_v2_onions = False
|
||||||
|
|
||||||
if self.save_private_key_checkbox.isChecked():
|
if self.save_private_key_checkbox.isChecked():
|
||||||
# force the legacy mode on
|
|
||||||
use_legacy_v2_onions = True
|
|
||||||
settings.set('save_private_key', True)
|
settings.set('save_private_key', True)
|
||||||
settings.set('private_key', self.old_settings.get('private_key'))
|
settings.set('private_key', self.old_settings.get('private_key'))
|
||||||
settings.set('slug', self.old_settings.get('slug'))
|
settings.set('slug', self.old_settings.get('slug'))
|
||||||
@ -982,12 +958,6 @@ class SettingsDialog(QtWidgets.QDialog):
|
|||||||
settings.set('use_legacy_v2_onions', True)
|
settings.set('use_legacy_v2_onions', True)
|
||||||
else:
|
else:
|
||||||
settings.set('use_legacy_v2_onions', False)
|
settings.set('use_legacy_v2_onions', False)
|
||||||
# If we are not using legacy mode, but we previously had persistence turned on, force it off!
|
|
||||||
settings.set('save_private_key', False)
|
|
||||||
settings.set('private_key', '')
|
|
||||||
settings.set('slug', '')
|
|
||||||
# Also unset the HidServAuth if we are removing our reusable private key
|
|
||||||
settings.set('hidservauth_string', '')
|
|
||||||
|
|
||||||
settings.set('data_dir', self.data_dir_lineedit.text())
|
settings.set('data_dir', self.data_dir_lineedit.text())
|
||||||
settings.set('public_mode', self.public_mode_checkbox.isChecked())
|
settings.set('public_mode', self.public_mode_checkbox.isChecked())
|
||||||
|
@ -88,8 +88,8 @@ class SettingsGuiBaseTest(object):
|
|||||||
if self.gui.onion.supports_v3_onions:
|
if self.gui.onion.supports_v3_onions:
|
||||||
# legacy mode is off
|
# legacy mode is off
|
||||||
self.assertFalse(self.gui.use_legacy_v2_onions_checkbox.isChecked())
|
self.assertFalse(self.gui.use_legacy_v2_onions_checkbox.isChecked())
|
||||||
# persistence, stealth is hidden and disabled
|
# persistence is still available, stealth is hidden and disabled
|
||||||
self.assertFalse(self.gui.save_private_key_widget.isVisible())
|
self.assertTrue(self.gui.save_private_key_widget.isVisible())
|
||||||
self.assertFalse(self.gui.save_private_key_checkbox.isChecked())
|
self.assertFalse(self.gui.save_private_key_checkbox.isChecked())
|
||||||
self.assertFalse(self.gui.use_stealth_widget.isVisible())
|
self.assertFalse(self.gui.use_stealth_widget.isVisible())
|
||||||
self.assertFalse(self.gui.stealth_checkbox.isChecked())
|
self.assertFalse(self.gui.stealth_checkbox.isChecked())
|
||||||
@ -107,7 +107,7 @@ class SettingsGuiBaseTest(object):
|
|||||||
# enable stealth mode
|
# enable stealth mode
|
||||||
QtTest.QTest.mouseClick(self.gui.stealth_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.stealth_checkbox.height()/2))
|
QtTest.QTest.mouseClick(self.gui.stealth_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.stealth_checkbox.height()/2))
|
||||||
self.assertTrue(self.gui.stealth_checkbox.isChecked())
|
self.assertTrue(self.gui.stealth_checkbox.isChecked())
|
||||||
# now that stealth, persistence are enabled, we can't turn off legacy mode
|
# now that stealth is enabled, we can't turn off legacy mode
|
||||||
self.assertFalse(self.gui.use_legacy_v2_onions_checkbox.isEnabled())
|
self.assertFalse(self.gui.use_legacy_v2_onions_checkbox.isEnabled())
|
||||||
# disable stealth, persistence
|
# disable stealth, persistence
|
||||||
QtTest.QTest.mouseClick(self.gui.save_private_key_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.save_private_key_checkbox.height()/2))
|
QtTest.QTest.mouseClick(self.gui.save_private_key_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.save_private_key_checkbox.height()/2))
|
||||||
@ -117,7 +117,7 @@ class SettingsGuiBaseTest(object):
|
|||||||
# uncheck legacy mode
|
# uncheck legacy mode
|
||||||
QtTest.QTest.mouseClick(self.gui.use_legacy_v2_onions_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.use_legacy_v2_onions_checkbox.height()/2))
|
QtTest.QTest.mouseClick(self.gui.use_legacy_v2_onions_checkbox, QtCore.Qt.LeftButton, pos=QtCore.QPoint(2,self.gui.use_legacy_v2_onions_checkbox.height()/2))
|
||||||
# legacy options hidden again
|
# legacy options hidden again
|
||||||
self.assertFalse(self.gui.save_private_key_widget.isVisible())
|
self.assertTrue(self.gui.save_private_key_widget.isVisible())
|
||||||
self.assertFalse(self.gui.use_stealth_widget.isVisible())
|
self.assertFalse(self.gui.use_stealth_widget.isVisible())
|
||||||
|
|
||||||
# re-enable legacy mode
|
# re-enable legacy mode
|
||||||
|
Loading…
x
Reference in New Issue
Block a user