Add windows support to is_ip
This commit is contained in:
parent
0b5b585992
commit
71183f6c19
|
@ -544,6 +544,10 @@ def is_ip(ip):
|
||||||
import socket
|
import socket
|
||||||
#first we test ipv4
|
#first we test ipv4
|
||||||
try:
|
try:
|
||||||
|
if windows_check():
|
||||||
|
if socket.inet_aton("%s" % (ip)):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
if socket.inet_pton(socket.AF_INET, "%s" % (ip)):
|
if socket.inet_pton(socket.AF_INET, "%s" % (ip)):
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
@ -551,6 +555,10 @@ def is_ip(ip):
|
||||||
return False
|
return False
|
||||||
#now test ipv6
|
#now test ipv6
|
||||||
try:
|
try:
|
||||||
|
if windows_check():
|
||||||
|
log.warning("ipv6 check unavailable on windows")
|
||||||
|
return True
|
||||||
|
else:
|
||||||
if socket.inet_pton(socket.AF_INET6, "%s" % (ip)):
|
if socket.inet_pton(socket.AF_INET6, "%s" % (ip)):
|
||||||
return True
|
return True
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
|
Loading…
Reference in New Issue