diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 008647ab..1a21a0e4 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2391,6 +2391,14 @@ class MyForm(settingsmixin.SMainWindow): QMessageBox.about(self, _translate("MainWindow", "Number needed"), _translate( "MainWindow", "Your maximum download and upload rate must be numbers. Ignoring what you typed.")) + try: + # Ensure we have an integer + BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', str( + int(float(self.settingsDialogInstance.ui.lineEditMaxOutboundConnections.text())))) + except: + QMessageBox.about(self, _translate("MainWindow", "Number needed"), _translate( + "MainWindow", "Your maximum outbound connections must be a number. Ignoring what you typed.")) + BMConfigParser().set('bitmessagesettings', 'namecoinrpctype', self.settingsDialogInstance.getNamecoinType()) BMConfigParser().set('bitmessagesettings', 'namecoinrpchost', str( @@ -4075,6 +4083,8 @@ class settingsDialog(QtGui.QDialog): BMConfigParser().get('bitmessagesettings', 'sockspassword'))) QtCore.QObject.connect(self.ui.comboBoxProxyType, QtCore.SIGNAL( "currentIndexChanged(int)"), self.comboBoxProxyTypeChanged) + self.ui.lineEditMaxOutboundConnections.setText(str( + shared.config.get('bitmessagesettings', 'maxoutboundconnections'))) self.ui.lineEditMaxDownloadRate.setText(str( BMConfigParser().get('bitmessagesettings', 'maxdownloadrate'))) self.ui.lineEditMaxUploadRate.setText(str( diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index 33b4c29d..54aea28d 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -154,6 +154,18 @@ class Ui_settingsDialog(object): self.lineEditMaxUploadRate.setMaximumSize(QtCore.QSize(60, 16777215)) self.lineEditMaxUploadRate.setObjectName(_fromUtf8("lineEditMaxUploadRate")) self.gridLayout_9.addWidget(self.lineEditMaxUploadRate, 1, 2, 1, 1) + self.label_26 = QtGui.QLabel(self.groupBox_3) + self.label_26.setObjectName(_fromUtf8("label_26")) + self.gridLayout_9.addWidget(self.label_26, 2, 1, 1, 1) + self.lineEditMaxOutboundConnections = QtGui.QLineEdit(self.groupBox_3) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.lineEditMaxOutboundConnections.sizePolicy().hasHeightForWidth()) + self.lineEditMaxOutboundConnections.setSizePolicy(sizePolicy) + self.lineEditMaxOutboundConnections.setMaximumSize(QtCore.QSize(60, 16777215)) + self.lineEditMaxOutboundConnections.setObjectName(_fromUtf8("lineEditMaxOutboundConnections")) + self.gridLayout_9.addWidget(self.lineEditMaxOutboundConnections, 2, 2, 1, 1) self.gridLayout_4.addWidget(self.groupBox_3, 2, 0, 1, 1) self.groupBox_2 = QtGui.QGroupBox(self.tabNetworkSettings) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) @@ -459,6 +471,7 @@ class Ui_settingsDialog(object): self.groupBox_3.setTitle(_translate("settingsDialog", "Bandwidth limit", None)) self.label_24.setText(_translate("settingsDialog", "Maximum download rate (kB/s): [0: unlimited]", None)) self.label_25.setText(_translate("settingsDialog", "Maximum upload rate (kB/s): [0: unlimited]", None)) + self.label_26.setText(_translate("settingsDialog", "Maximum outbound connections: [0: none]", None)) self.groupBox_2.setTitle(_translate("settingsDialog", "Proxy server / Tor", None)) self.label_2.setText(_translate("settingsDialog", "Type:", None)) self.label_3.setText(_translate("settingsDialog", "Server hostname:", None)) diff --git a/src/bitmessageqt/settings.ui b/src/bitmessageqt/settings.ui index 475821f8..4aeba3ce 100644 --- a/src/bitmessageqt/settings.ui +++ b/src/bitmessageqt/settings.ui @@ -317,6 +317,29 @@ + + + + Maximum outbound connections: [0: none] + + + + + + + + 0 + 0 + + + + + 60 + 16777215 + + + + diff --git a/src/class_outgoingSynSender.py b/src/class_outgoingSynSender.py index 1754962e..b6b55b99 100644 --- a/src/class_outgoingSynSender.py +++ b/src/class_outgoingSynSender.py @@ -79,7 +79,7 @@ class outgoingSynSender(threading.Thread, StoppableThread): self.stop.wait(2) while BMConfigParser().safeGetBoolean('bitmessagesettings', 'sendoutgoingconnections') and not self._stopped: self.name = "outgoingSynSender" - maximumConnections = 1 if shared.trustedPeer else 8 # maximum number of outgoing connections = 8 + maximumConnections = 1 if shared.trustedPeer else shared.config.getint('bitmessagesettings', 'maxoutboundconnections') while len(self.selfInitiatedConnections[self.streamNumber]) >= maximumConnections: self.stop.wait(10) if shared.shutdown: diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index df747aea..2ed37e59 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -433,6 +433,16 @@ class sqlThread(threading.Thread): BMConfigParser().set('bitmessagesettings', 'smtpdeliver', '') if not BMConfigParser().has_option('bitmessagesettings', 'hidetrayconnectionnotifications'): BMConfigParser().set('bitmessagesettings', 'hidetrayconnectionnotifications', 'false') + if BMConfigParser().has_option('bitmessagesettings', 'maxoutboundconnections'): + try: + # Ensure we have an integer + int(float(BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections'))) + except: + logger.fatal('Your maximum outbound connections must be a number.') + os._exit(0) + else: + BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', '8') + shared.writeKeysFile() # Are you hoping to add a new option to the keys.dat file of existing diff --git a/src/helper_startup.py b/src/helper_startup.py index 86d3de42..5739f314 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -108,6 +108,7 @@ def loadConfig(): BMConfigParser().set('bitmessagesettings', 'replybelow', 'False') BMConfigParser().set('bitmessagesettings', 'maxdownloadrate', '0') BMConfigParser().set('bitmessagesettings', 'maxuploadrate', '0') + BMConfigParser().set('bitmessagesettings', 'maxoutboundconnections', '8') BMConfigParser().set('bitmessagesettings', 'ttl', '367200') #start:UI setting to stop trying to send messages after X days/months