Bpeel ipv6 #661

Merged
Atheros1 merged 2 commits from bpeel-ipv6 into master 2014-04-28 00:10:08 +02:00
2 changed files with 22 additions and 1 deletions
Showing only changes of commit 114ba4e23a - Show all commits

View File

@ -59,7 +59,24 @@ class outgoingSynSender(threading.Thread):
address_family = socket.AF_INET address_family = socket.AF_INET
else: else:
address_family = socket.AF_INET6 address_family = socket.AF_INET6
try:
sock = socks.socksocket(address_family, socket.SOCK_STREAM) sock = socks.socksocket(address_family, socket.SOCK_STREAM)
except:
"""
The line can fail on Windows systems which aren't
64-bit compatiable:
File "C:\Python27\lib\socket.py", line 187, in __init__
_sock = _realsocket(family, type, proto)
error: [Errno 10047] An address incompatible with the requested protocol was used
So let us remove the offending address from our knownNodes file.
"""
shared.knownNodesLock.acquire()
del shared.knownNodes[self.streamNumber][peer]
shared.knownNodesLock.release()
with shared.printLock:
print 'deleting ', peer, 'from shared.knownNodes because it caused a socks.socksocket exception. We must not be 64-bit compatible.'
continue
# This option apparently avoids the TIME_WAIT state so that we # This option apparently avoids the TIME_WAIT state so that we
# can rebind faster # can rebind faster
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

View File

@ -622,6 +622,10 @@ class receiveDataThread(threading.Thread):
continue continue
else: else:
hostFromAddrMessage = socket.inet_ntop(socket.AF_INET6, fullHost) hostFromAddrMessage = socket.inet_ntop(socket.AF_INET6, fullHost)
if hostFromAddrMessage == "":
# This can happen on Windows systems which are not 64-bit compatible
# so let us drop the IPv6 address.
continue
if not self._checkIPv6Address(fullHost, hostFromAddrMessage): if not self._checkIPv6Address(fullHost, hostFromAddrMessage):
continue continue
timeSomeoneElseReceivedMessageFromThisNode, = unpack('>Q', data[lengthOfNumberOfAddresses + ( timeSomeoneElseReceivedMessageFromThisNode, = unpack('>Q', data[lengthOfNumberOfAddresses + (