Add windows support to is_ip
This commit is contained in:
parent
ba4ca111c6
commit
0e4101a9a3
|
@ -553,15 +553,23 @@ def is_ip(ip):
|
||||||
import socket
|
import socket
|
||||||
#first we test ipv4
|
#first we test ipv4
|
||||||
try:
|
try:
|
||||||
if socket.inet_pton(socket.AF_INET, "%s" % (ip)):
|
if windows_check():
|
||||||
return True
|
if socket.inet_aton("%s" % (ip)):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
if socket.inet_pton(socket.AF_INET, "%s" % (ip)):
|
||||||
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
if not socket.has_ipv6:
|
if not socket.has_ipv6:
|
||||||
return False
|
return False
|
||||||
#now test ipv6
|
#now test ipv6
|
||||||
try:
|
try:
|
||||||
if socket.inet_pton(socket.AF_INET6, "%s" % (ip)):
|
if windows_check():
|
||||||
|
log.warning("ipv6 check unavailable on windows")
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
if socket.inet_pton(socket.AF_INET6, "%s" % (ip)):
|
||||||
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue