setting, openssl and bmproto quality fixes

This commit is contained in:
lakshya 2020-05-18 21:30:13 +05:30
parent c69decaab3
commit 3f773c78f7
No known key found for this signature in database
GPG Key ID: 7D81A5565D14CB2B
3 changed files with 35 additions and 31 deletions

View File

@ -1,3 +1,6 @@
"""
This module setting file is for settings
"""
import ConfigParser
import os
import sys
@ -110,7 +113,7 @@ class SettingsDialog(QtGui.QDialog):
tempfile.NamedTemporaryFile(
dir=paths.lookupExeFolder(), delete=True
).close() # should autodelete
except:
except Exception:
self.checkBoxPortableMode.setDisabled(True)
if 'darwin' in sys.platform:
@ -407,14 +410,14 @@ class SettingsDialog(QtGui.QDialog):
self.config.set(
'bitmessagesettings', 'defaultnoncetrialsperbyte',
str(int(
float(self.lineEditTotalDifficulty.text()) *
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
float(self.lineEditTotalDifficulty.text())
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
if float(self.lineEditSmallMessageDifficulty.text()) >= 1:
self.config.set(
'bitmessagesettings', 'defaultpayloadlengthextrabytes',
str(int(
float(self.lineEditSmallMessageDifficulty.text()) *
defaults.networkDefaultPayloadLengthExtraBytes)))
float(self.lineEditSmallMessageDifficulty.text())
* defaults.networkDefaultPayloadLengthExtraBytes)))
if self.comboBoxOpenCL.currentText().toUtf8() != self.config.safeGet(
'bitmessagesettings', 'opencl'):
@ -426,40 +429,40 @@ class SettingsDialog(QtGui.QDialog):
acceptableDifficultyChanged = False
if (
float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1 or
float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0
float(self.lineEditMaxAcceptableTotalDifficulty.text()) >= 1
or float(self.lineEditMaxAcceptableTotalDifficulty.text()) == 0
):
if self.config.get(
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte'
) != str(int(
float(self.lineEditMaxAcceptableTotalDifficulty.text()) *
defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
float(self.lineEditMaxAcceptableTotalDifficulty.text())
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte)
):
# the user changed the max acceptable total difficulty
acceptableDifficultyChanged = True
self.config.set(
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte',
str(int(
float(self.lineEditMaxAcceptableTotalDifficulty.text()) *
defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
float(self.lineEditMaxAcceptableTotalDifficulty.text())
* defaults.networkDefaultProofOfWorkNonceTrialsPerByte))
)
if (
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1 or
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) >= 1
or float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) == 0
):
if self.config.get(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes'
) != str(int(
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) *
defaults.networkDefaultPayloadLengthExtraBytes)
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text())
* defaults.networkDefaultPayloadLengthExtraBytes)
):
# the user changed the max acceptable small message difficulty
acceptableDifficultyChanged = True
self.config.set(
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes',
str(int(
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text()) *
defaults.networkDefaultPayloadLengthExtraBytes))
float(self.lineEditMaxAcceptableSmallMessageDifficulty.text())
* defaults.networkDefaultPayloadLengthExtraBytes))
)
if acceptableDifficultyChanged:
# It might now be possible to send msgs which were previously
@ -537,8 +540,8 @@ class SettingsDialog(QtGui.QDialog):
self.parent.updateStartOnLogon()
if (
state.appdata != paths.lookupExeFolder() and
self.checkBoxPortableMode.isChecked()
state.appdata != paths.lookupExeFolder()
and self.checkBoxPortableMode.isChecked()
):
# If we are NOT using portable mode now but the user selected
# that we should...
@ -556,12 +559,12 @@ class SettingsDialog(QtGui.QDialog):
try:
os.remove(previousAppdataLocation + 'debug.log')
os.remove(previousAppdataLocation + 'debug.log.1')
except:
except Exception:
pass
if (
state.appdata == paths.lookupExeFolder() and
not self.checkBoxPortableMode.isChecked()
state.appdata == paths.lookupExeFolder()
and not self.checkBoxPortableMode.isChecked()
):
# If we ARE using portable mode now but the user selected
# that we shouldn't...
@ -579,5 +582,5 @@ class SettingsDialog(QtGui.QDialog):
try:
os.remove(paths.lookupExeFolder() + 'debug.log')
os.remove(paths.lookupExeFolder() + 'debug.log.1')
except:
except Exception:
pass

View File

@ -441,9 +441,10 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if stream not in state.streamsInWhichIAmParticipating:
continue
if (
decodedIP and time.time() - seenTime > 0 and
seenTime > time.time() - ADDRESS_ALIVE and
port > 0
decodedIP
and time.time() - seenTime > 0
and seenTime > time.time() - ADDRESS_ALIVE
and port > 0
):
peer = Peer(decodedIP, port)
try:
@ -541,8 +542,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
logger.debug(
'%(host)s:%(port)i sending version',
self.destination._asdict())
if ((self.services & protocol.NODE_SSL == protocol.NODE_SSL) and
protocol.haveSSL(not self.isOutbound)):
if ((self.services & protocol.NODE_SSL == protocol.NODE_SSL)
and protocol.haveSSL(not self.isOutbound)):
self.isSSL = True
if not self.verackReceived:
return True
@ -600,7 +601,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
'Closed connection to %s because we are already'
' connected to that IP.', self.destination)
return False
except:
except Exception:
pass
if not self.isOutbound:
# incoming from a peer we're connected to as outbound,

View File

@ -453,7 +453,7 @@ class _OpenSSL(object):
try:
self.PKCS5_PBKDF2_HMAC = self._lib.PKCS5_PBKDF2_HMAC
except:
except Exception:
# The above is not compatible with all versions of OSX.
self.PKCS5_PBKDF2_HMAC = self._lib.PKCS5_PBKDF2_HMAC_SHA1
@ -794,7 +794,7 @@ def loadOpenSSL():
try:
OpenSSL = _OpenSSL(library)
return
except:
except Exception:
pass
raise Exception(
"Couldn't find and load the OpenSSL library. You must install it.")