Preliminary Tor hidden service support
This commit is contained in:
parent
7c3703aee0
commit
5abeec5c5c
|
@ -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:
|
||||
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):
|
||||
|
|
|
@ -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 == "":
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user