def get_address_type(address, resolve=False): if is_ipv4_address(address): return ADDR_IPV4 if is_ipv6_address(address): return ADDR_IPV6 if resolve: try: socket.getaddrinfo(address, None) except socket.gaierror: return ADDR_UNRESOLVABLE return ADDR_FQDN
def get_address_type(address, resolve=False): if is_ipv4_address(address): return ADDR_IPV4 if is_ipv6_address(address): return ADDR_IPV6 if resolve: try: socket.getaddrinfo(address, None) except socket.gaierror: return ADDR_UNRESOLVABLE return ADDR_FQDN
def test_bad(self): self.assertFalse(validate.is_ipv6_address("abcd")) self.assertFalse(validate.is_ipv6_address("192.168.1.1")) self.assertFalse(validate.is_ipv6_address(1234))
def test_valid(self): self.assertTrue(validate.is_ipv6_address("fe80::5054:ff:fec6:8eaf")) self.assertTrue(validate.is_ipv6_address("::abc:7:def"))
def test_bad(self): self.assertFalse(validate.is_ipv6_address("abcd")) self.assertFalse(validate.is_ipv6_address("192.168.1.1"))
def test_valid(self): self.assertTrue(validate.is_ipv6_address("fe80::5054:ff:fec6:8eaf")) self.assertTrue(validate.is_ipv6_address("::abc:7:def"))