printself,'connected to',HOST,'during an outgoing attempt.'
shared.printLock.release()
withshared.printLock:
printself,'connected to',HOST,'during an outgoing attempt.'
sd=sendDataThread()
sd.setup(sock,HOST,PORT,self.streamNumber,
@ -128,18 +128,18 @@ class outgoingSynSender(threading.Thread):
exceptsocks.GeneralProxyErroraserr:
ifshared.verbose>=2:
shared.printLock.acquire()
print'Could NOT connect to',HOST,'during outgoing attempt.',err
shared.printLock.release()
withshared.printLock:
print'Could NOT connect to',HOST,'during outgoing attempt.',err
PORT,timeLastSeen=shared.knownNodes[
self.streamNumber][HOST]
if(int(time.time())-timeLastSeen)>172800andlen(shared.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the shared.knownNodes data-structure.
shared.knownNodesLock.acquire()
delshared.knownNodes[self.streamNumber][HOST]
shared.knownNodesLock.release()
shared.printLock.acquire()
print'deleting ',HOST,'from shared.knownNodes because it is more than 48 hours old and we could not connect to it.'
shared.printLock.release()
withshared.printLock:
print'deleting ',HOST,'from shared.knownNodes because it is more than 48 hours old and we could not connect to it.'
exceptsocks.Socks5AuthErroraserr:
shared.UISignalQueue.put((
'updateStatusBar',tr.translateText(
@ -154,18 +154,18 @@ class outgoingSynSender(threading.Thread):
print'Bitmessage MIGHT be having trouble connecting to the SOCKS server. '+str(err)
else:
ifshared.verbose>=1:
shared.printLock.acquire()
print'Could NOT connect to',HOST,'during outgoing attempt.',err
shared.printLock.release()
withshared.printLock:
print'Could NOT connect to',HOST,'during outgoing attempt.',err
PORT,timeLastSeen=shared.knownNodes[
self.streamNumber][HOST]
if(int(time.time())-timeLastSeen)>172800andlen(shared.knownNodes[self.streamNumber])>1000:# for nodes older than 48 hours old if we have more than 1000 hosts in our list, delete from the knownNodes data-structure.
shared.knownNodesLock.acquire()
delshared.knownNodes[self.streamNumber][HOST]
shared.knownNodesLock.release()
shared.printLock.acquire()
print'deleting ',HOST,'from knownNodes because it is more than 48 hours old and we could not connect to it.'
shared.printLock.release()
withshared.printLock:
print'deleting ',HOST,'from knownNodes because it is more than 48 hours old and we could not connect to it.'
exceptExceptionaserr:
sys.stderr.write(
'An exception has occurred in the outgoingSynSender thread that was not caught by other exception types: ')
print'The size of the connectedHostsList is now:',len(shared.connectedHostsList)
shared.printLock.release()
withshared.printLock:
print'The size of the connectedHostsList is now:',len(shared.connectedHostsList)
defprocessData(self):
# if shared.verbose >= 3:
# shared.printLock.acquire()
# print 'self.data is currently ', repr(self.data)
# shared.printLock.release()
# with shared.printLock:
# print 'self.data is currently ', repr(self.data)
#
iflen(self.data)<20:# if so little of the data has arrived that we can't even unpack the payload length
return
ifself.data[0:4]!='\xe9\xbe\xb4\xd9':
ifshared.verbose>=1:
shared.printLock.acquire()
print'The magic bytes were not correct. First 40 bytes of data: '+repr(self.data[0:40])
shared.printLock.release()
withshared.printLock:
print'The magic bytes were not correct. First 40 bytes of data: '+repr(self.data[0:40])
self.data=""
return
self.payloadLength,=unpack('>L',self.data[16:20])
@ -142,9 +142,9 @@ class receiveDataThread(threading.Thread):
shared.knownNodesLock.release()
ifself.payloadLength<=180000000:# If the size of the message is greater than 180MB, ignore it. (I get memory errors when processing messages much larger than this though it is concievable that this value will have to be lowered if some systems are less tolarant of large messages.)
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
shared.printLock.release()
withshared.printLock:
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
self.HOST]# this data structure is maintained so that we can keep track of how many total objects, across all connections, are currently outstanding. If it goes too high it can indicate that we are under attack by multiple nodes working together.
@ -205,18 +205,18 @@ class receiveDataThread(threading.Thread):
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
shared.printLock.release()
withshared.printLock:
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
self.HOST]# this data structure is maintained so that we can keep track of how many total objects, across all connections, are currently outstanding. If it goes too high it can indicate that we are under attack by multiple nodes working together.
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
shared.printLock.release()
withshared.printLock:
print'(concerning',self.HOST+')','number of objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave is now',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)
self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave)# this data structure is maintained so that we can keep track of how many total objects, across all connections, are currently outstanding. If it goes too high it can indicate that we are under attack by multiple nodes working together.
iflen(self.ackDataThatWeHaveYetToSend)>0:
@ -244,9 +244,9 @@ class receiveDataThread(threading.Thread):
@ -932,9 +933,9 @@ class receiveDataThread(threading.Thread):
exceptExceptionaserr:
print'ECDSA verify failed',err
return
shared.printLock.acquire()
print'As a matter of intellectual curiosity, here is the Bitcoin address associated with the keys owned by the other person:',helper_bitcoin.calculateBitcoinAddressFromPubkey(pubSigningKey),' ..and here is the testnet address:',helper_bitcoin.calculateTestnetAddressFromPubkey(pubSigningKey),'. The other person must take their private signing key from Bitmessage and import it into Bitcoin (or a service like Blockchain.info) for it to be of any use. Do not use this unless you know what you are doing.'
shared.printLock.release()
withshared.printLock:
print'As a matter of intellectual curiosity, here is the Bitcoin address associated with the keys owned by the other person:',helper_bitcoin.calculateBitcoinAddressFromPubkey(pubSigningKey),' ..and here is the testnet address:',helper_bitcoin.calculateTestnetAddressFromPubkey(pubSigningKey),'. The other person must take their private signing key from Bitmessage and import it into Bitcoin (or a service like Blockchain.info) for it to be of any use. Do not use this unless you know what you are doing.'
# calculate the fromRipe.
sha=hashlib.new('sha512')
sha.update(pubSigningKey+pubEncryptionKey)
@ -980,9 +981,9 @@ class receiveDataThread(threading.Thread):
queryreturn=shared.sqlReturnQueue.get()
shared.sqlLock.release()
ifqueryreturn!=[]:
shared.printLock.acquire()
print'Message ignored because address is in blacklist.'
shared.printLock.release()
withshared.printLock:
print'Message ignored because address is in blacklist.'
blockMessage=True
else:# We're using a whitelist
t=(fromAddress,)
@ -1081,10 +1082,10 @@ class receiveDataThread(threading.Thread):
'(Within the recgetpubkey function) Someone requested one of my pubkeys but the requestedAddressVersionNumber doesn\'t match my actual address version number. That shouldn\'t have happened. Ignoring.\n')
shared.printLock.release()
withshared.printLock:
sys.stderr.write(
'(Within the recgetpubkey function) Someone requested one of my pubkeys but the requestedAddressVersionNumber doesn\'t match my actual address version number. That shouldn\'t have happened. Ignoring.\n')
return
try:
lastPubkeySendTime=int(shared.config.get(
@ -1431,9 +1432,9 @@ class receiveDataThread(threading.Thread):
except:
lastPubkeySendTime=0
iflastPubkeySendTime<time.time()-shared.lengthOfTimeToHoldOnToAllPubkeys:# If the last time we sent our pubkey was at least 28 days ago...
shared.printLock.acquire()
print'Found getpubkey-requested-hash in my list of EC hashes. Telling Worker thread to do the POW for a pubkey message and send it out.'
shared.printLock.release()
withshared.printLock:
print'Found getpubkey-requested-hash in my list of EC hashes. Telling Worker thread to do the POW for a pubkey message and send it out.'
ifrequestedAddressVersionNumber==2:
shared.workerQueue.put((
'doPOWForMyV2Pubkey',requestedHash))
@ -1441,13 +1442,13 @@ class receiveDataThread(threading.Thread):
shared.workerQueue.put((
'doPOWForMyV3Pubkey',requestedHash))
else:
shared.printLock.acquire()
print'Found getpubkey-requested-hash in my list of EC hashes BUT we already sent it recently. Ignoring request. The lastPubkeySendTime is:',lastPubkeySendTime
shared.printLock.release()
withshared.printLock:
print'Found getpubkey-requested-hash in my list of EC hashes BUT we already sent it recently. Ignoring request. The lastPubkeySendTime is:',lastPubkeySendTime
else:
shared.printLock.acquire()
print'This getpubkey request is not for any of my keys.'
shared.printLock.release()
withshared.printLock:
print'This getpubkey request is not for any of my keys.'
# We have received an inv message
defrecinv(self,data):
@ -1455,10 +1456,10 @@ class receiveDataThread(threading.Thread):
print'number of keys(hosts) in shared.numberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHavePerPeer:',len(shared.numberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHavePerPeer)
print'number of keys(hosts) in shared.numberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHavePerPeer:',len(shared.numberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHavePerPeer)
print'We already have',totalNumberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave,'items yet to retrieve from peers and over 1000 from this node in particular. Ignoring this inv message.'
shared.printLock.release()
withshared.printLock:
print'We already have',totalNumberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave,'items yet to retrieve from peers and over 1000 from this node in particular. Ignoring this inv message.'
print'Inventory (SQL on disk) has inventory item already.'
else:
@ -1487,9 +1488,9 @@ class receiveDataThread(threading.Thread):
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.
iflen(data[lengthOfVarint+(32*i):32+lengthOfVarint+(32*i)])==32:# The length of an inventory hash should be 32. If it isn't 32 then the remote node is either badly programmed or behaving nefariously.
print'We already have',totalNumberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave,'items yet to retrieve from peers and over',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave),'from this node in particular. Ignoring the rest of this inv message.'
shared.printLock.release()
withshared.printLock:
print'We already have',totalNumberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave,'items yet to retrieve from peers and over',len(self.objectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHave),'from this node in particular. Ignoring the rest of this inv message.'