slightly modify IPv6 modifications so that IPv4-only hosts properly handle v6 IPs
This commit is contained in:
parent
7da6ea958f
commit
114ba4e23a
|
@ -59,7 +59,24 @@ class outgoingSynSender(threading.Thread):
|
|||
address_family = socket.AF_INET
|
||||
else:
|
||||
address_family = socket.AF_INET6
|
||||
sock = socks.socksocket(address_family, socket.SOCK_STREAM)
|
||||
try:
|
||||
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
|
||||
# can rebind faster
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
|
|
@ -622,6 +622,10 @@ class receiveDataThread(threading.Thread):
|
|||
continue
|
||||
else:
|
||||
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):
|
||||
continue
|
||||
timeSomeoneElseReceivedMessageFromThisNode, = unpack('>Q', data[lengthOfNumberOfAddresses + (
|
||||
|
|
Loading…
Reference in New Issue
Block a user