Changed asn and ipinfo function output and caching
This commit is contained in:
@@ -185,12 +185,13 @@ def _asn(ip):
|
||||
res['name']=" ".join(name_split[:-1])
|
||||
return res
|
||||
|
||||
@disk_cache_decorator()
|
||||
@functools.lru_cache(maxsize=1000)
|
||||
def asn(ip, type="asn"):
|
||||
if len(ip.split(",")) > 1:
|
||||
return ",".join([_asn(x, type) for x in ip.split(",")])
|
||||
try:
|
||||
return _asn(ip)[type]
|
||||
record = _asn(ip)
|
||||
return f'({record["asn"]}:{record["name"]}[{record["country"]}]'
|
||||
except:
|
||||
return ""
|
||||
|
||||
@@ -206,12 +207,15 @@ def _ipinfo(ip):
|
||||
except ModuleNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1000)
|
||||
def ipinfo(ip, type="country"):
|
||||
if len(ip.split(",")) > 1:
|
||||
return ",".join([ipinfo(x, type) for x in ip.split(",")])
|
||||
try:
|
||||
if type:
|
||||
return _ipinfo(ip)[type]
|
||||
else:
|
||||
return _ipinfo(ip)
|
||||
except:
|
||||
return ""
|
||||
|
||||
@@ -225,6 +229,7 @@ def split_number2ip(number):
|
||||
else:
|
||||
return number
|
||||
|
||||
@functools.lru_cache(maxsize=1000)
|
||||
def mx_lookup(domain):
|
||||
domain = domain.lstrip("www.")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user