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