Add generic ip address validation function

This commit is contained in:
Erik Johnson 2018-11-27 11:55:54 -06:00
parent 9f547205a0
commit d1c2038081
No known key found for this signature in database
GPG Key ID: 5E5583C437808F3F

View File

@ -81,6 +81,14 @@ def ipv6_addr(addr):
return __ip_addr(addr, socket.AF_INET6)
def ip_addr(addr):
'''
Returns True if the IPv4 or IPv6 address (and optional subnet) are valid,
otherwise returns False.
'''
return ipv4_addr(addr) or ipv6_addr(addr)
def netmask(mask):
'''
Returns True if the value passed is a valid netmask, otherwise return False