diff options
author | Paul Sokolovsky <paul.sokolovsky@linaro.org> | 2014-03-27 21:48:02 +0200 |
---|---|---|
committer | Paul Sokolovsky <paul.sokolovsky@linaro.org> | 2014-03-28 01:37:28 +0200 |
commit | bbf997eafaa3f40cc2278bd784636b77b6b716c5 (patch) | |
tree | f078b19d4229a86cc5d8a6aa0007377b4f97ab27 | |
parent | fb5683f0ebbe6e67c353518366bac81848c6c9b9 (diff) |
iploc: Optimize IP address parsing.
Change-Id: Ieeac354aeee0ed10b8732b19183aa0320caac07a
-rw-r--r-- | iploc.py | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -9,6 +9,7 @@ import struct import sys import os import optparse +import socket from bsddb3 import db @@ -49,10 +50,9 @@ temp_user = "" def get_reverse_dns(ip_address): # XXX: this works only with IPv4 addresses (because dnshistory works only with IPv4) - octets = str(ip_address).split('.') # The keys in the the reverse DNS db are stored as a char encoded string # made from the single octet of the IP address. - key = ''.join(chr(int(x)) for x in octets) + key = socket.inet_aton(ip_address) value = REVERSE_DNS_DB.get(key) struct_sz = struct.calcsize("li") assert len(value) > struct_sz |