allowing for max connection configuration #939
No reviewers
Labels
No Label
bug
build
dependencies
developers
documentation
duplicate
enhancement
formatting
invalid
legal
mobile
obsolete
packaging
performance
protocol
question
refactoring
regression
security
test
translation
usability
wontfix
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Bitmessage/PyBitmessage-2024-12-19#939
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "maxconnection-config"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This allows for the maximum number of connections to be configured in the settings UI.
Please change the variable name to maxoutboundconnections or something like that, because maxconnections is confusing. Also please change label_26 accordingly.
I'm redesigning the network subsystem to asyncore so most of it will be scrapped, but the GUI changes and the variable I plan on keeping.
Other than that it looks ok, please give me a couple of days for a closer code review, I'm fixing some other stuff so don't have time today. I don't think I'll have to test it very long.
Will do. Thanks.
Done.
Add a check here to ensure the option is a number if it exists
@ -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."))
Refer to the immediately preceding options to see how to ensure the user entered a number.
Ensure the option is a number when changing it and reading from disk to avoid crashing the outgoingSynSender threads and preventing new outgoing connections if it is not a number.
@ -436,0 +438,4 @@
# Ensure we have an integer
int(float(BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections')))
except:
logger.fatal('Your maximum outbound connections must be a number.')
This should simply log an error and set it to 8 instead of dying.
@ -2392,2 +2392,4 @@
"MainWindow", "Your maximum download and upload rate must be numbers. Ignoring what you typed."))
try:
# Ensure we have an integer
Instead of this whole exception handling, try something like
lineEditMaxOutboundConnections.setValidator(QIntValidator(1, 1024, lineEditMaxOutboundConnections))
in settings.py (1 being the lower limit, 1024 the top).
For a more complex example look into newchandialog.py and addressvalidator.py, in your case you don't need a new validator class, you can use the QIntValidator as it is.
@ -157,0 +164,4 @@
sizePolicy.setHeightForWidth(self.lineEditMaxOutboundConnections.sizePolicy().hasHeightForWidth())
self.lineEditMaxOutboundConnections.setSizePolicy(sizePolicy)
self.lineEditMaxOutboundConnections.setMaximumSize(QtCore.QSize(60, 16777215))
self.lineEditMaxOutboundConnections.setObjectName(_fromUtf8("lineEditMaxOutboundConnections"))
how about also
self.lineEditMaxOutboundConnections.setPlaceholderText(_fromUtf8("8"))
@ -2392,2 +2392,4 @@
"MainWindow", "Your maximum download and upload rate must be numbers. Ignoring what you typed."))
try:
# Ensure we have an integer
👍
@ -436,0 +436,4 @@
if BMConfigParser().has_option('bitmessagesettings', 'maxoutboundconnections'):
try:
# Ensure we have an integer
int(float(BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections')))
Maybe
if BMConfigParser().getint('bitmessagesettings', 'maxoutboundconnections'))) < 1: throw ValueException
@ -436,0 +437,4 @@
try:
# Ensure we have an integer
int(float(BMConfigParser().get('bitmessagesettings', 'maxoutboundconnections')))
except:
And this should be
except ValueException:
because you're supposed to always name the exception. I haven't always done it but in new code we should try to do that.
Closing in favor of https://github.com/Bitmessage/PyBitmessage/pull/940.