Make it possible to disable UDP announcing in settings

This commit is contained in:
Dmitri Bogomolov 2020-09-16 18:41:51 +03:00
parent ef849d2dd3
commit 8ff8e0e2cb
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
4 changed files with 53 additions and 23 deletions

View File

@ -321,9 +321,10 @@ class Main(object):
receiveQueueThread = ReceiveQueueThread(i) receiveQueueThread = ReceiveQueueThread(i)
receiveQueueThread.daemon = True receiveQueueThread.daemon = True
receiveQueueThread.start() receiveQueueThread.start()
announceThread = AnnounceThread() if config.safeGetBoolean('bitmessagesettings', 'udp'):
announceThread.daemon = True state.announceThread = AnnounceThread()
announceThread.start() state.announceThread.daemon = True
state.announceThread.start()
state.invThread = InvThread() state.invThread = InvThread()
state.invThread.daemon = True state.invThread.daemon = True
state.invThread.start() state.invThread.start()

View File

@ -19,7 +19,7 @@ import widgets
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlStoredProcedure from helper_sql import sqlExecute, sqlStoredProcedure
from helper_startup import start_proxyconfig from helper_startup import start_proxyconfig
from network import knownnodes from network import knownnodes, AnnounceThread
from network.asyncore_pollchoose import set_rates from network.asyncore_pollchoose import set_rates
from tr import _translate from tr import _translate
@ -138,6 +138,8 @@ class SettingsDialog(QtGui.QDialog):
config.get('bitmessagesettings', 'port'))) config.get('bitmessagesettings', 'port')))
self.checkBoxUPnP.setChecked( self.checkBoxUPnP.setChecked(
config.safeGetBoolean('bitmessagesettings', 'upnp')) config.safeGetBoolean('bitmessagesettings', 'upnp'))
self.checkBoxUDP.setChecked(
config.safeGetBoolean('bitmessagesettings', 'udp'))
self.checkBoxAuthentication.setChecked( self.checkBoxAuthentication.setChecked(
config.getboolean('bitmessagesettings', 'socksauthentication')) config.getboolean('bitmessagesettings', 'socksauthentication'))
self.checkBoxSocksListen.setChecked( self.checkBoxSocksListen.setChecked(
@ -326,7 +328,8 @@ class SettingsDialog(QtGui.QDialog):
self.lineEditTCPPort.text()): self.lineEditTCPPort.text()):
self.config.set( self.config.set(
'bitmessagesettings', 'port', str(self.lineEditTCPPort.text())) 'bitmessagesettings', 'port', str(self.lineEditTCPPort.text()))
if not self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'): if not self.config.safeGetBoolean(
'bitmessagesettings', 'dontconnect'):
self.net_restart_needed = True self.net_restart_needed = True
if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean( if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean(
@ -339,11 +342,26 @@ class SettingsDialog(QtGui.QDialog):
upnpThread = upnp.uPnPThread() upnpThread = upnp.uPnPThread()
upnpThread.start() upnpThread.start()
udp_enabled = self.checkBoxUDP.isChecked()
if udp_enabled != self.config.safeGetBoolean(
'bitmessagesettings', 'udp'):
self.config.set('bitmessagesettings', 'udp', str(udp_enabled))
if udp_enabled:
announceThread = AnnounceThread()
announceThread.daemon = True
announceThread.start()
else:
try:
state.announceThread.stopThread()
except AttributeError:
pass
proxytype_index = self.comboBoxProxyType.currentIndex() proxytype_index = self.comboBoxProxyType.currentIndex()
if proxytype_index == 0: if proxytype_index == 0:
if self._proxy_type and state.statusIconColor != 'red': if self._proxy_type and state.statusIconColor != 'red':
self.net_restart_needed = True self.net_restart_needed = True
elif state.statusIconColor == 'red' and self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'): elif state.statusIconColor == 'red' and self.config.safeGetBoolean(
'bitmessagesettings', 'dontconnect'):
self.net_restart_needed = False self.net_restart_needed = False
elif self.comboBoxProxyType.currentText() != self._proxy_type: elif self.comboBoxProxyType.currentText() != self._proxy_type:
self.net_restart_needed = True self.net_restart_needed = True
@ -369,8 +387,11 @@ class SettingsDialog(QtGui.QDialog):
self.lineEditSocksPassword.text())) self.lineEditSocksPassword.text()))
self.config.set('bitmessagesettings', 'sockslisten', str( self.config.set('bitmessagesettings', 'sockslisten', str(
self.checkBoxSocksListen.isChecked())) self.checkBoxSocksListen.isChecked()))
if self.checkBoxOnionOnly.isChecked() \ if (
and not self.config.safeGetBoolean('bitmessagesettings', 'onionservicesonly'): self.checkBoxOnionOnly.isChecked()
and not self.config.safeGetBoolean(
'bitmessagesettings', 'onionservicesonly')
):
self.net_restart_needed = True self.net_restart_needed = True
self.config.set('bitmessagesettings', 'onionservicesonly', str( self.config.set('bitmessagesettings', 'onionservicesonly', str(
self.checkBoxOnionOnly.isChecked())) self.checkBoxOnionOnly.isChecked()))
@ -432,8 +453,8 @@ class SettingsDialog(QtGui.QDialog):
acceptableDifficultyChanged = False acceptableDifficultyChanged = False
if ( if (
float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1
or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0 or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0
): ):
if self.config.get( if self.config.get(
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte' 'bitmessagesettings', 'maxacceptablenoncetrialsperbyte'
@ -449,8 +470,8 @@ class SettingsDialog(QtGui.QDialog):
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)) * defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
) )
if ( if (
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1
or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0 or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
): ):
if self.config.get( if self.config.get(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes' 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes'
@ -541,8 +562,8 @@ class SettingsDialog(QtGui.QDialog):
self.parent.updateStartOnLogon() self.parent.updateStartOnLogon()
if ( if (
state.appdata != paths.lookupExeFolder() state.appdata != paths.lookupExeFolder()
and self.checkBoxPortableMode.isChecked() and self.checkBoxPortableMode.isChecked()
): ):
# If we are NOT using portable mode now but the user selected # If we are NOT using portable mode now but the user selected
# that we should... # that we should...
@ -564,8 +585,8 @@ class SettingsDialog(QtGui.QDialog):
pass pass
if ( if (
state.appdata == paths.lookupExeFolder() state.appdata == paths.lookupExeFolder()
and not self.checkBoxPortableMode.isChecked() and not self.checkBoxPortableMode.isChecked()
): ):
# If we ARE using portable mode now but the user selected # If we ARE using portable mode now but the user selected
# that we shouldn't... # that we shouldn't...

View File

@ -231,7 +231,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>Bandwidth limit</string> <string>Bandwidth limit</string>
@ -322,7 +322,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>Proxy server / Tor</string> <string>Proxy server / Tor</string>
@ -432,7 +432,14 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="1" column="0">
<widget class="QCheckBox" name="checkBoxUDP">
<property name="text">
<string>Announce self by UDP</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>

View File

@ -19,24 +19,25 @@ BMConfigDefaults = {
"maxtotalconnections": 200, "maxtotalconnections": 200,
"maxuploadrate": 0, "maxuploadrate": 0,
"apiinterface": "127.0.0.1", "apiinterface": "127.0.0.1",
"apiport": 8442 "apiport": 8442,
"udp": "True"
}, },
"threads": { "threads": {
"receive": 3, "receive": 3,
}, },
"network": { "network": {
"bind": '', "bind": "",
"dandelion": 90, "dandelion": 90,
}, },
"inventory": { "inventory": {
"storage": "sqlite", "storage": "sqlite",
"acceptmismatch": False, "acceptmismatch": "False",
}, },
"knownnodes": { "knownnodes": {
"maxnodes": 20000, "maxnodes": 20000,
}, },
"zlib": { "zlib": {
'maxsize': 1048576 "maxsize": 1048576
} }
} }