mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-05-20 02:45:24 +00:00
Reverse-lookup cache improvements (#501)
This commit is contained in:
@@ -48,7 +48,7 @@ MAGIC_GZIP = b"\x1F\x8B"
|
||||
MAGIC_XML = b"\x3c\x3f\x78\x6d\x6c\x20"
|
||||
MAGIC_JSON = b"\7b"
|
||||
|
||||
IP_ADDRESS_CACHE = ExpiringDict(max_len=10000, max_age_seconds=1800)
|
||||
IP_ADDRESS_CACHE = ExpiringDict(max_len=10000, max_age_seconds=14400)
|
||||
REVERSE_DNS_MAP = dict()
|
||||
|
||||
|
||||
|
||||
+7
-7
@@ -172,7 +172,8 @@ def get_reverse_dns(ip_address, cache=None, nameservers=None, timeout=2.0):
|
||||
nameservers=nameservers,
|
||||
timeout=timeout)[0]
|
||||
|
||||
except dns.exception.DNSException:
|
||||
except dns.exception.DNSException as e:
|
||||
logger.warning(f"get_reverse_dns({ip_address}) exception: {e}")
|
||||
pass
|
||||
|
||||
return hostname
|
||||
@@ -396,10 +397,6 @@ def get_ip_address_info(ip_address,
|
||||
if info:
|
||||
logger.debug(f"IP address {ip_address} was found in cache")
|
||||
return info
|
||||
else:
|
||||
logger.debug(f"IP address {ip_address} not found in cache")
|
||||
else:
|
||||
logger.debug("IP address cache was not specified")
|
||||
info = OrderedDict()
|
||||
info["ip_address"] = ip_address
|
||||
if offline:
|
||||
@@ -427,8 +424,11 @@ def get_ip_address_info(ip_address,
|
||||
info["type"] = service["type"]
|
||||
info["name"] = service["name"]
|
||||
|
||||
if cache is not None:
|
||||
cache[ip_address] = info
|
||||
if cache is not None:
|
||||
cache[ip_address] = info
|
||||
logger.debug(f"IP address {ip_address} added to cache")
|
||||
else:
|
||||
logger.debug(f"IP address {ip_address} reverse_dns not found")
|
||||
|
||||
return info
|
||||
|
||||
|
||||
Reference in New Issue
Block a user