Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
 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))
Beispiel #4
0
 def test_valid(self):
     self.assertTrue(validate.is_ipv6_address("fe80::5054:ff:fec6:8eaf"))
     self.assertTrue(validate.is_ipv6_address("::abc:7:def"))
Beispiel #5
0
 def test_bad(self):
     self.assertFalse(validate.is_ipv6_address("abcd"))
     self.assertFalse(validate.is_ipv6_address("192.168.1.1"))
Beispiel #6
0
 def test_valid(self):
     self.assertTrue(validate.is_ipv6_address("fe80::5054:ff:fec6:8eaf"))
     self.assertTrue(validate.is_ipv6_address("::abc:7:def"))