#Right now, PyBitmessage only support connecting to stream 1. It doesn't yet contain logic to expand into further streams.
softwareVersion='0.2.0'
softwareVersion='0.2.1'
verbose=2
maximumAgeOfAnObjectThatIAmWillingToAccept=216000#Equals two days and 12 hours.
lengthOfTimeToLeaveObjectsInInventory=237600#Equals two days and 18 hours. This should be longer than maximumAgeOfAnObjectThatIAmWillingToAccept so that we don't process messages twice.
@ -126,14 +126,15 @@ class outgoingSynSender(QThread):
@ -168,7 +169,7 @@ class outgoingSynSender(QThread):
print'deleting ',HOST,'from knownNodes because it is more than 48 hours old and we could not connect to it.'
exceptException,err:
print'An exception has occurred in the outgoingSynSender thread that was not caught by other exception types:',err
time.sleep(1)
time.sleep(0.1)
#Only one singleListener thread will ever exist. It creates the receiveDataThread and sendDataThread for each incoming connection. Note that it cannot set the stream number because it is not known yet- the other node will have to tell us its stream number in a version message. If we don't care about their stream, we will close the connection (within the recversion function of the recieveData thread)
@ -241,7 +243,7 @@ class receiveDataThread(QThread):
else:
self.initiatedConnection=True
self.ackDataThatWeHaveYetToSend=[]#When we receive a message bound for us, we store the acknowledgement that we need to send (the ackdata) here until we are done processing all other data received from this peer.
print'Not including an object hash in a big inv message because the remote node is already aware of it.'#This line is here to check that this feature is working.
printLock.release()
#We also have messages in our inventory in memory (which is a python dictionary). Let's fetch those too.
print'Not including an object hash in a big inv message because the remote node is already aware of it.'#This line is here to check that this feature is working.
printLock.release()
numberOfObjectsInInvMessage=0
payload=''
#Now let us start appending all of these hashes together. They will be sent out in a big inv message to our new peer.
@ -468,7 +479,7 @@ class receiveDataThread(QThread):
#Now let's send the acknowledgement. We'll need to make sure that our client will properly process the ackData; if the packet is malformed, we could clear out self.data and an attacker could use that behavior to determine that we were capable of decoding this message.
#Now let's consider sending the acknowledgement. We'll need to make sure that our client will properly process the ackData; if the packet is malformed, we could clear out self.data and an attacker could use that behavior to determine that we were capable of decoding this message.
ackDataValidThusFar=True
iflen(ackData)<24:
print'The length of ackData is unreasonably short. Not sending ackData.'
@ -911,9 +924,7 @@ class receiveDataThread(QThread):
self.ackDataThatWeHaveYetToSend.append(ackData)#When we have processed all data, the processData function will pop the ackData out and process it as if it is a message received from our peer.
#print 'self.data after:', repr(self.data)
#This section is for my RSA keys (version 1 addresses). If we don't have any version 1 addresses, then it won't matter.
@ -1124,6 +1135,7 @@ class receiveDataThread(QThread):
print'We have already received this pubkey. Ignoring it.'
@ -1136,7 +1148,7 @@ class receiveDataThread(QThread):
readPosition=24#for the message header
readPosition+=8#for the nonce
embeddedTime=self.data[readPosition:readPosition+4]#We currently are not checking the embeddedTime for any sort of validity in pubkey messages.
embeddedTime,=unpack('>I',self.data[readPosition:readPosition+4])#We currently are not checking the embeddedTime for any sort of validity in pubkey messages.
foriinrange(numberOfItemsInInv):#upon finishing dealing with an incoming message, the receiveDataThread will request a random object from the peer. This way if we get multiple inv messages from multiple peers which list mostly the same objects, we will make getdata requests for different random objects from the various peers.
#print 'Adding object to self.objectsThatWeHaveYetToGet.'
print'The streamNumber of this sendDataThread (ID:',id(self),') at setup() is',self.streamNumber
printLock.release()
@ -1815,12 +1824,11 @@ class sendDataThread(QThread):
print'setting the stream number in the sendData thread (ID:',id(self),') to',specifiedStreamNumber
printLock.release()
self.streamNumber=specifiedStreamNumber
elifcommand=='send':
elifcommand=='sendaddr':
try:
#To prevent some network analysis, 'leak' the data out to our peer after waiting a random amount of time unless we have a long list of messages in our queue to send.
ifself.mailbox.qsize()<20:
random.seed()
time.sleep(random.randrange(0,10))
random.seed()
time.sleep(random.randrange(0,10))
self.sock.sendall(data)
self.lastTimeISentData=int(time.time())
except:
@ -1829,6 +1837,25 @@ class sendDataThread(QThread):
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Broadcast sent at '+strftime(config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))))
@ -2355,12 +2372,7 @@ class singleWorker(QThread):
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Broadcast sent at '+strftime(config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))))
@ -2547,12 +2559,7 @@ class singleWorker(QThread):
self.emit(SIGNAL("updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"),ackdata,'Message sent. Waiting on acknowledgement. Sent on '+strftime(config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))))
print'sending inv (within sendmsg function)'
payload='\x01'+inventoryHash
headerData='\xe9\xbe\xb4\xd9'#magic bits, slighly different from Bitcoin's magic bits.
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("updateSentItemStatusByHash(PyQt_PyObject,PyQt_PyObject)"),ripe,'Sending public key request. Waiting for reply. Requested at '+strftime(config.get('bitmessagesettings','timeformat'),localtime(int(time.time()))))