added cloudflare detection / badge on results page
This commit is contained in:
@@ -336,6 +336,9 @@ def enrich_whois(hostname: str) -> dict:
|
||||
|
||||
def enrich_geoip(hostname: str) -> dict:
|
||||
"""Resolve hostname to IPs and fetch info from ip-api.com."""
|
||||
|
||||
CLOUDFLARE_ASN = "AS13335 Cloudflare"
|
||||
|
||||
geo_info = {}
|
||||
ips = extract_ips_from_url(hostname)
|
||||
for ip in ips:
|
||||
@@ -352,6 +355,12 @@ def enrich_geoip(hostname: str) -> dict:
|
||||
resp = requests.get(f"http://ip-api.com/json/{ip_str}?fields=24313855", timeout=5)
|
||||
if resp.status_code == 200:
|
||||
geo_info[ip_str] = resp.json()
|
||||
asname = geo_info[ip_str].get("as")
|
||||
|
||||
# if behind cloudflare
|
||||
if CLOUDFLARE_ASN in asname:
|
||||
geo_info[ip_str].update({"cloudflare":True})
|
||||
|
||||
else:
|
||||
geo_info[ip_str] = {"error": f"HTTP {resp.status_code}"}
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user