Exemplo n.º 1
0
    def testInetAtoN(self):
        for address in ipv6_addresses.IPV6_ADDRESSES:
            self.assertEqual(ipv6_utils.InetAtoN(address),
                             socket.inet_pton(socket.AF_INET6, address))

        for address in ipv6_addresses.BAD_IPV6_ADDRESSES:
            self.assertRaises(socket.error, ipv6_utils.InetAtoN, address)
Exemplo n.º 2
0
 def human_readable_address(self, value):
     if ":" in value:
         # IPv6
         self.address_type = NetworkAddress.Family.INET6
         self.packed_bytes = ipv6_utils.InetAtoN(value)
     else:
         # IPv4
         self.address_type = NetworkAddress.Family.INET
         self.packed_bytes = socket.inet_aton(value)