def ip_type(self): if not self.first_ip: return '' return ipu.get_version(self.first_ip)
def matches(self, ip): ip_type = ipu.get_version(ip) for r in self.ranges(ip_type): if ip in r: return True return False
def test_IPV6_if_only_colons(self): self.assertEqual(ipu.IPv6, ipu.get_version('::')) self.assertEqual(ipu.IPv6, ipu.get_version('::1'))
def test_IPV4_if_no_colons(self): self.assertEqual(ipu.IPv4, ipu.get_version('192.168.1.1'))
def test_IPV6_if_both_colons_and_dots(self): self.assertEqual(ipu.IPv6, ipu.get_version('::ffff:129.144.52.38'))