-
-
-def valid_ipv4(ip_address):
- """Check IPv4 address.
-
- :param ip_address: IPv4 address to check.
- :type ip_address: str
- :returns: True if IP address is correct.
- :rtype: bool
- """
- try:
- ipaddress.IPv4Address(ip_address)
- return True
- except (AttributeError, ipaddress.AddressValueError):
- return False
-
-
-def valid_ipv6(ip_address):
- """Check IPv6 address.
-
- :param ip_address: IPv6 address to check.
- :type ip_address: str
- :returns: True if IP address is correct.
- :rtype: bool
- """
- try:
- ipaddress.IPv6Address(ip_address)
- return True
- except (AttributeError, ipaddress.AddressValueError):
- return False