don't try to use GUPnP-IGD when we use an IPv6 address

This commit is contained in:
Yann Leboulanger 2015-12-15 22:25:39 +01:00
parent 48a2486d60
commit cb36bc7abe
1 changed files with 10 additions and 4 deletions

View File

@ -421,6 +421,15 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
self.connection.send(iq)
return
my_ip = self.peerhost[0]
# check if we are connected with an IPv4 address
try:
socket.inet_aton(my_ip)
except socket.error as e:
self.connection.send(iq)
return
def ip_is_local(ip):
if '.' not in ip:
# it's an IPv6
@ -439,9 +448,6 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
return True
return False
my_ip = self.peerhost[0]
if not ip_is_local(my_ip):
self.connection.send(iq)
return
@ -475,7 +481,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
cleanup_gupnp()
def fail(s, error, proto, ext_ip, local_ip, local_port, desc):
log.debug('Got GUPnP-IGD error : %s', str(error))
log.debug('Got GUPnP-IGD error')
self.connection.send(iq)
cleanup_gupnp()