mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-05-21 11:25:23 +00:00
Use cache in get_ip_address_info. (#494)
This commit is contained in:
+9
-1
@@ -313,10 +313,15 @@ def get_ip_address_info(ip_address, ip_db_path=None, cache=None, offline=False,
|
||||
|
||||
"""
|
||||
ip_address = ip_address.lower()
|
||||
if cache:
|
||||
if cache is not None:
|
||||
info = cache.get(ip_address, None)
|
||||
if info:
|
||||
logger.debug("IP address " + ip_address + " was found in cache")
|
||||
return info
|
||||
else:
|
||||
logger.debug("IP address " + ip_address + " not found in cache")
|
||||
else:
|
||||
logger.debug("IP address cache not specified")
|
||||
info = OrderedDict()
|
||||
info["ip_address"] = ip_address
|
||||
if offline:
|
||||
@@ -333,6 +338,9 @@ def get_ip_address_info(ip_address, ip_db_path=None, cache=None, offline=False,
|
||||
base_domain = get_base_domain(reverse_dns)
|
||||
info["base_domain"] = base_domain
|
||||
|
||||
if cache is not None:
|
||||
cache[ip_address] = info
|
||||
|
||||
return info
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user