From dd35c7b4af5d069036b29946bacc3d8227f53fc7 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 18 Feb 2013 15:01:47 -0500 Subject: [PATCH] Improved error reporting to help diagnose why Bitmessage is having trouble finding OpenSSL on Debian, and also small changes --- bitmessagemain.py | 12 ++++++++---- messages.dat reader.py | 14 +++++++++++++- pyelliptic/openssl.py | 6 ++++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/bitmessagemain.py b/bitmessagemain.py index 335640c9..a68a2425 100644 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -314,7 +314,7 @@ class receiveDataThread(QThread): self.data = "" else: self.payloadLength, = unpack('>L',self.data[16:20]) - if len(self.data) >= self.payloadLength: #check if the whole message has arrived yet. If it has,... + if len(self.data) >= self.payloadLength+24: #check if the whole message has arrived yet. If it has,... if self.data[20:24] == hashlib.sha512(self.data[24:self.payloadLength+24]).digest()[0:4]:#test the checksum in the message. If it is correct... #print 'message checksum is correct' #The time we've last seen this node is obviously right now since we just received valid data from it. So update the knownNodes list so that other peers can be made aware of its existance. @@ -2071,6 +2071,7 @@ def reloadMyAddressHashes(): print 'reloading keys from keys.dat file' printLock.release() myRSAAddressHashes.clear() + myECAddressHashes.clear() #myPrivateKeys.clear() configSections = config.sections() for addressInKeysFile in configSections: @@ -2283,6 +2284,8 @@ class singleCleaner(QThread): #self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Message sent again because the acknowledgement was never received. ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time())))) workerQueue.put(('sendmessage',toaddress)) sqlLock.release() + #Clear the status bar in case a message has been sitting there for a while. + self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),"") #This thread, of which there is only one, does the heavy lifting: calculating POWs. class singleWorker(QThread): @@ -2742,7 +2745,7 @@ class singleWorker(QThread): nonce = 0 trialValue = 99999999999999999999 #print 'trial value', trialValue - statusbar = 'Doing the computations necessary to request the recipient''s public key. (Doing the proof-of-work.)' + statusbar = 'Doing the computations necessary to request the recipient\'s public key.' self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),statusbar) self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),ripe,'Doing work necessary to request public key.') print 'Doing proof-of-work necessary to send getpubkey message.' @@ -2763,7 +2766,7 @@ class singleWorker(QThread): #payload = '\x01' + pack('>H',objectType) + hash broadcastToSendDataQueues((streamNumber, 'sendinv', inventoryHash)) - self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Broacasting the public key request. The recipient''s software must be on. This program will auto-retry if they are offline.') + self.emit(SIGNAL("updateStatusBar(PyQt_PyObject)"),'Broacasting the public key request. This program will auto-retry if they are offline.') self.emit(SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),ripe,'Sending public key request. Waiting for reply. Requested at ' + strftime(config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time())))) def generateFullAckMessage(self,ackdata,toStreamNumber,embeddedTime): @@ -3482,6 +3485,7 @@ class MyForm(QtGui.QMainWindow): self.singleCleanerThread = singleCleaner() self.singleCleanerThread.start() QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"), self.updateSentItemStatusByHash) + QtCore.QObject.connect(self.singleCleanerThread, QtCore.SIGNAL("updateStatusBar(PyQt_PyObject)"), self.updateStatusBar) self.workerThread = singleWorker() self.workerThread.start() @@ -4545,7 +4549,7 @@ if __name__ == "__main__": #This appears to be the first time running the program; there is no config file (or it cannot be accessed). Create config file. config.add_section('bitmessagesettings') config.set('bitmessagesettings','settingsversion','1') - config.set('bitmessagesettings','bitstrength','2048') + #config.set('bitmessagesettings','bitstrength','2048') config.set('bitmessagesettings','port','8444') config.set('bitmessagesettings','timeformat','%%a, %%d %%b %%Y %%I:%%M %%p') config.set('bitmessagesettings','blackwhitelist','black') diff --git a/messages.dat reader.py b/messages.dat reader.py index 0e27f0ec..60c3ddd4 100644 --- a/messages.dat reader.py +++ b/messages.dat reader.py @@ -60,6 +60,17 @@ def readPubkeys(): hash, havecorrectnonce, transmitdata, time, usedpersonally = row print 'Hash:', hash.encode('hex'), '\tHave correct nonce:', havecorrectnonce, '\tTime first broadcast:', strftime('%a, %d %b %Y %I:%M %p',localtime(time)), '\tUsed by me personally:', usedpersonally, '\tFull pubkey message:', transmitdata.encode('hex') +def readInventory(): + print 'Printing everything in inventory table:' + item = '''select hash, objecttype, streamnumber, payload, receivedtime from inventory''' + parameters = '' + cur.execute(item, parameters) + output = cur.fetchall() + for row in output: + hash, objecttype, streamnumber, payload, receivedtime = row + print 'Hash:', hash.encode('hex'), objecttype, streamnumber, '\t', payload.encode('hex'), '\t', strftime('%a, %d %b %Y %I:%M %p',localtime(receivedtime)) + + def takeInboxMessagesOutOfTrash(): item = '''update inbox set folder='inbox' where folder='trash' ''' parameters = '' @@ -80,7 +91,8 @@ def takeSentMessagesOutOfTrash(): #takeSentMessagesOutOfTrash() #readInbox() #readSent() -readPubkeys() +#readPubkeys() #readSubscriptions() +readInventory() diff --git a/pyelliptic/openssl.py b/pyelliptic/openssl.py index 3dc0ee24..1e98e368 100644 --- a/pyelliptic/openssl.py +++ b/pyelliptic/openssl.py @@ -424,6 +424,8 @@ except: from ctypes.util import find_library OpenSSL = _OpenSSL(find_library('ssl')) except Exception, err: - raise Exception("Couldn't load the OpenSSL library. You must install it. Error message:"+err) + sys.stderr.write('(On Linux) Couldn\'t find and load the OpenSSL library. You must install it. If you believe that you already have it installed, this exception information might be of use:\n') + from ctypes.util import find_library + OpenSSL = _OpenSSL(find_library('ssl')) else: - raise Exception("Couldn't load the OpenSSL library. You must install it.") + raise Exception("Couldn't find and load the OpenSSL library. You must install it.")