Closes #1538. Changes 'onionservicesonly=true' to 'onlynet=onion'.
Old-style 'onionservicesonly' is deprecated but still accepted. The configuration option will be upgraded upon the first GUI settings update.
This commit is contained in:
parent
9265235053
commit
7b168b7041
|
@ -358,6 +358,11 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
if proxytype_index > 2: # last literal proxytype in ui
|
if proxytype_index > 2: # last literal proxytype in ui
|
||||||
start_proxyconfig()
|
start_proxyconfig()
|
||||||
|
|
||||||
|
onionOnly_deprecated = BMConfigParser().safeGetBoolean(
|
||||||
|
"bitmessagesettings", "onionservicesonly")
|
||||||
|
onionOnly = BMConfigParser().safeGet(
|
||||||
|
"bitmessagesettings", "onlynet") == "onion"
|
||||||
|
onionOnly = onionOnly or onionOnly_deprecated
|
||||||
self.config.set('bitmessagesettings', 'socksauthentication', str(
|
self.config.set('bitmessagesettings', 'socksauthentication', str(
|
||||||
self.checkBoxAuthentication.isChecked()))
|
self.checkBoxAuthentication.isChecked()))
|
||||||
self.config.set('bitmessagesettings', 'sockshostname', str(
|
self.config.set('bitmessagesettings', 'sockshostname', str(
|
||||||
|
@ -371,10 +376,20 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.config.set('bitmessagesettings', 'sockslisten', str(
|
self.config.set('bitmessagesettings', 'sockslisten', str(
|
||||||
self.checkBoxSocksListen.isChecked()))
|
self.checkBoxSocksListen.isChecked()))
|
||||||
if self.checkBoxOnionOnly.isChecked() \
|
if self.checkBoxOnionOnly.isChecked() \
|
||||||
and not self.config.safeGetBoolean('bitmessagesettings', 'onionservicesonly'):
|
and not onionOnly:
|
||||||
self.net_restart_needed = True
|
self.net_restart_needed = True
|
||||||
self.config.set('bitmessagesettings', 'onionservicesonly', str(
|
if self.checkBoxOnionOnly.isChecked():
|
||||||
self.checkBoxOnionOnly.isChecked()))
|
self.config.set('bitmessagesettings', 'onlynet', 'onion')
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
return self.config.remove_option('bitmessagesettings', 'onlynet')
|
||||||
|
except ConfigParser.NoOptionError:
|
||||||
|
pass
|
||||||
|
# Remove deprecated onionservicesonly option if it exists:
|
||||||
|
try:
|
||||||
|
return self.config.remove_option('bitmessagesettings', 'onionservicesonly')
|
||||||
|
except ConfigParser.NoOptionError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
# Rounding to integers just for aesthetics
|
# Rounding to integers just for aesthetics
|
||||||
self.config.set('bitmessagesettings', 'maxdownloadrate', str(
|
self.config.set('bitmessagesettings', 'maxdownloadrate', str(
|
||||||
|
|
|
@ -31,8 +31,11 @@ def chooseConnection(stream):
|
||||||
"""Returns an appropriate connection"""
|
"""Returns an appropriate connection"""
|
||||||
haveOnion = BMConfigParser().safeGet(
|
haveOnion = BMConfigParser().safeGet(
|
||||||
"bitmessagesettings", "socksproxytype")[0:5] == 'SOCKS'
|
"bitmessagesettings", "socksproxytype")[0:5] == 'SOCKS'
|
||||||
onionOnly = BMConfigParser().safeGetBoolean(
|
onionOnly_deprecated = BMConfigParser().safeGetBoolean(
|
||||||
"bitmessagesettings", "onionservicesonly")
|
"bitmessagesettings", "onionservicesonly")
|
||||||
|
onionOnly = BMConfigParser().safeGet(
|
||||||
|
"bitmessagesettings", "onlynet") == "onion"
|
||||||
|
onionOnly = onionOnly or onionOnly_deprecated
|
||||||
try:
|
try:
|
||||||
retval = portCheckerQueue.get(False)
|
retval = portCheckerQueue.get(False)
|
||||||
portCheckerQueue.task_done()
|
portCheckerQueue.task_done()
|
||||||
|
|
|
@ -194,14 +194,7 @@ class TestCore(unittest.TestCase):
|
||||||
start_proxyconfig()
|
start_proxyconfig()
|
||||||
self._check_bootstrap()
|
self._check_bootstrap()
|
||||||
|
|
||||||
@unittest.skipUnless(stem_version, 'No stem, skipping tor dependent test')
|
def _check_exclusively_onion_networking(self):
|
||||||
def test_onionservicesonly(self): # this should start after bootstrap
|
|
||||||
"""
|
|
||||||
set onionservicesonly, wait for 3 connections and check them all
|
|
||||||
are onions
|
|
||||||
"""
|
|
||||||
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5')
|
|
||||||
BMConfigParser().set('bitmessagesettings', 'onionservicesonly', 'true')
|
|
||||||
self._initiate_bootstrap()
|
self._initiate_bootstrap()
|
||||||
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
BMConfigParser().remove_option('bitmessagesettings', 'dontconnect')
|
||||||
for _ in range(360):
|
for _ in range(360):
|
||||||
|
@ -218,6 +211,25 @@ class TestCore(unittest.TestCase):
|
||||||
% peer.host)
|
% peer.host)
|
||||||
self.fail('Failed to connect to at least 3 nodes within 360 sec')
|
self.fail('Failed to connect to at least 3 nodes within 360 sec')
|
||||||
|
|
||||||
|
@unittest.skipUnless(stem_version, 'No stem, skipping tor dependent test')
|
||||||
|
def test_onionservicesonly(self): # this should start after bootstrap
|
||||||
|
"""
|
||||||
|
set onionservicesonly (deprecated), wait for 3 connections and check
|
||||||
|
that all are onions
|
||||||
|
"""
|
||||||
|
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5')
|
||||||
|
BMConfigParser().set('bitmessagesettings', 'onionservicesonly', 'true')
|
||||||
|
self._check_exclusively_onion_networking()
|
||||||
|
|
||||||
|
@unittest.skipUnless(stem_version, 'No stem, skipping tor dependent test')
|
||||||
|
def test_onlynetonion(self): # this should start after bootstrap
|
||||||
|
"""
|
||||||
|
set onlynet=onion, wait for 3 connections and check that all are onions
|
||||||
|
"""
|
||||||
|
BMConfigParser().set('bitmessagesettings', 'socksproxytype', 'SOCKS5')
|
||||||
|
BMConfigParser().set('bitmessagesettings', 'onlynet', 'onion')
|
||||||
|
self._check_exclusively_onion_networking()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _decode_msg(data, pattern):
|
def _decode_msg(data, pattern):
|
||||||
proto = BMProto()
|
proto = BMProto()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user