added cloudflare detection / badge on results page

This commit is contained in:
2025-09-03 10:11:47 -05:00
parent b59bf67329
commit d5cc9df699
3 changed files with 12 additions and 21 deletions

View File

@@ -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: