Solved python3 database issue and now network connection created via using the python3 db
This commit is contained in:
parent
3ac7076836
commit
5ff6c26efc
|
@ -486,7 +486,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
|||
continue
|
||||
except KeyError:
|
||||
pass
|
||||
if len(knownnodes.knownNodes[stream]) < BMConfigParser().safeGetInt("knownnodes", "maxnodes"):
|
||||
if len(knownnodes.knownNodes[stream]) < int(BMConfigParser().safeGet("knownnodes", "maxnodes")):
|
||||
with knownnodes.knownNodesLock:
|
||||
try:
|
||||
knownnodes.knownNodes[stream][peer]["lastseen"] = seenTime
|
||||
|
|
|
@ -326,7 +326,11 @@ class BMConnectionPool(object):
|
|||
continue
|
||||
|
||||
try:
|
||||
if chosen.host.endswith(".onion") and Proxy.onion_proxy:
|
||||
if type(chosen.host) == bytes:
|
||||
onion= '.onion'.encode()
|
||||
else:
|
||||
onion = '.onion'
|
||||
if chosen.host.endswith(onion) and Proxy.onion_proxy:
|
||||
if onionsocksproxytype == "SOCKS5":
|
||||
self.addConnection(Socks5BMConnection(chosen))
|
||||
elif onionsocksproxytype == "SOCKS4a":
|
||||
|
|
|
@ -69,9 +69,14 @@ class TCPConnection(BMProto, TLSDispatcher):
|
|||
else:
|
||||
self.destination = address
|
||||
self.isOutbound = True
|
||||
try:
|
||||
self.create_socket(
|
||||
socket.AF_INET6 if ":" in address.host else socket.AF_INET,
|
||||
socket.SOCK_STREAM)
|
||||
except TypeError:
|
||||
self.create_socket(
|
||||
socket.AF_INET6 if ':'.encode() in address.host else socket.AF_INET,
|
||||
socket.SOCK_STREAM)
|
||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
TLSDispatcher.__init__(self, sock, server_side=False)
|
||||
self.connect(self.destination)
|
||||
|
|
|
@ -96,9 +96,17 @@ def isBitSetWithinBitfield(fourByteString, n):
|
|||
|
||||
def encodeHost(host):
|
||||
"""Encode a given host to be used in low-level socket operations"""
|
||||
if host.find('.onion') > -1:
|
||||
return '\xfd\x87\xd8\x7e\xeb\x43'.encode('utf-8') + base64.b32decode(host.split(".")[0], True)
|
||||
elif host.find(':') == -1:
|
||||
if type(host) == bytes:
|
||||
onion = 'onion'.encode()
|
||||
colon = ':'.encode()
|
||||
full_stop = '.'.encode()
|
||||
else:
|
||||
onion = 'onion'
|
||||
colon = ':'
|
||||
full_stop = '.'
|
||||
if host.find(onion) > -1:
|
||||
return '\xfd\x87\xd8\x7e\xeb\x43'.encode('raw_unicode_escape') + base64.b32decode(host.split(full_stop)[0], True)
|
||||
elif host.find(colon) == -1:
|
||||
return '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF'.encode('raw_unicode_escape') + \
|
||||
socket.inet_aton(host)
|
||||
return socket.inet_pton(socket.AF_INET6, host)
|
||||
|
|
Reference in New Issue
Block a user