Preliminary Tor hidden service support
This commit is contained in:
parent
c5363c3c5e
commit
143abe3c34
|
@ -29,14 +29,19 @@ class outgoingSynSender(threading.Thread, StoppableThread):
|
||||||
# If the user has specified a trusted peer then we'll only
|
# If the user has specified a trusted peer then we'll only
|
||||||
# ever connect to that. Otherwise we'll pick a random one from
|
# ever connect to that. Otherwise we'll pick a random one from
|
||||||
# the known nodes
|
# the known nodes
|
||||||
shared.knownNodesLock.acquire()
|
|
||||||
if shared.trustedPeer:
|
if shared.trustedPeer:
|
||||||
|
shared.knownNodesLock.acquire()
|
||||||
peer = shared.trustedPeer
|
peer = shared.trustedPeer
|
||||||
shared.knownNodes[self.streamNumber][peer] = time.time()
|
shared.knownNodes[self.streamNumber][peer] = time.time()
|
||||||
|
shared.knownNodesLock.release()
|
||||||
else:
|
else:
|
||||||
peer, = random.sample(shared.knownNodes[self.streamNumber], 1)
|
while True:
|
||||||
shared.knownNodesLock.release()
|
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
|
return peer
|
||||||
|
|
||||||
def stopThread(self):
|
def stopThread(self):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
doTimingAttackMitigation = False
|
doTimingAttackMitigation = False
|
||||||
|
|
||||||
|
import base64
|
||||||
import errno
|
import errno
|
||||||
import math
|
import math
|
||||||
import time
|
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':
|
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:])
|
hostStandardFormat = socket.inet_ntop(socket.AF_INET, host[12:])
|
||||||
return self._checkIPv4Address(host[12:], hostStandardFormat)
|
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:
|
else:
|
||||||
hostStandardFormat = socket.inet_ntop(socket.AF_INET6, host)
|
hostStandardFormat = socket.inet_ntop(socket.AF_INET6, host)
|
||||||
if hostStandardFormat == "":
|
if hostStandardFormat == "":
|
||||||
|
|
|
@ -9,6 +9,7 @@ useVeryEasyProofOfWorkForTesting = False # If you set this to True while on the
|
||||||
|
|
||||||
|
|
||||||
# Libraries.
|
# Libraries.
|
||||||
|
import base64
|
||||||
import collections
|
import collections
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import os
|
import os
|
||||||
|
@ -150,7 +151,7 @@ def isInSqlInventory(hash):
|
||||||
|
|
||||||
def encodeHost(host):
|
def encodeHost(host):
|
||||||
if host.find('.onion') > -1:
|
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:
|
elif host.find(':') == -1:
|
||||||
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF' + \
|
||||||
socket.inet_aton(host)
|
socket.inet_aton(host)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user