V0.6 #852

Merged
Atheros1 merged 399 commits from v0.6 into master 2016-05-03 01:58:38 +02:00
3 changed files with 16 additions and 5 deletions
Showing only changes of commit 143abe3c34 - Show all commits

View File

@ -29,14 +29,19 @@ class outgoingSynSender(threading.Thread, StoppableThread):
# If the user has specified a trusted peer then we'll only
# ever connect to that. Otherwise we'll pick a random one from
# the known nodes
shared.knownNodesLock.acquire()
if shared.trustedPeer:
shared.knownNodesLock.acquire()
peer = shared.trustedPeer
shared.knownNodes[self.streamNumber][peer] = time.time()
shared.knownNodesLock.release()
else:
peer, = random.sample(shared.knownNodes[self.streamNumber], 1)
shared.knownNodesLock.release()
while True:
shared.knownNodesLock.acquire()
peer, = random.sample(shared.knownNodes[self.streamNumber], 1)
shared.knownNodesLock.release()
if shared.config.get('bitmessagesettings', 'socksproxytype') != 'none' or peer.host.find(".onion") == -1:
break
time.sleep(1)
return peer
def stopThread(self):

View File

@ -1,5 +1,6 @@
doTimingAttackMitigation = False
import base64
import errno
import math
import time
@ -517,6 +518,10 @@ class receiveDataThread(threading.Thread):
if host[0:12] == '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF':
hostStandardFormat = socket.inet_ntop(socket.AF_INET, host[12:])
return self._checkIPv4Address(host[12:], hostStandardFormat)
elif host[0:6] == '\xfd\x87\xd8\x7e\xeb\x43':
# Onion, based on BMD/bitcoind
hostStandardFormat = base64.b32encode(host[6:]).lower() + ".onion"
return hostStandardFormat
else:
hostStandardFormat = socket.inet_ntop(socket.AF_INET6, host)
if hostStandardFormat == "":

View File

@ -9,6 +9,7 @@ useVeryEasyProofOfWorkForTesting = False # If you set this to True while on the
# Libraries.
import base64
import collections
import ConfigParser
import os
@ -150,7 +151,7 @@ def isInSqlInventory(hash):
def encodeHost(host):
if host.find('.onion') > -1:
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x7F\x00\x00\x01'
return '\xfd\x87\xd8\x7e\xeb\x43' + base64.b32decode(host.split(".")[0], True)
elif host.find(':') == -1:
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
socket.inet_aton(host)