import asyncio import aiodns from urllib.parse import urlparse # Simple highly-reputable baseline list TOP_DOMAINS = {"google.com", "apple.com", "microsoft.com", "amazon.com", "netflix.com"} async def analyze_network_footprint(url: str) -> float: score = 0.0 hostname = urlparse(url).hostname or "" if not hostname: return 0.0 # Base domain extraction (e.g., www.google.com -> google.com) domain_parts = hostname.split('.') base_domain = ".".join(domain_parts[-2:]) if len(domain_parts) >= 2 else hostname if base_domain in TOP_DOMAINS: return 0.0 # Highly reputable infrastructure bypasses structural anomaly traps resolver = aiodns.DNSResolver() try: a_records = await resolver.query(hostname, 'A') if len(a_records) > 3: score += 0.3 if a_records: first_ip = a_records[0].host ip_parts = first_ip.split('.') arpa_addr = f"{'.'.join(reversed(ip_parts))}.in-addr.arpa" try: await resolver.query(arpa_addr, 'PTR') except aiodns.error.DNSError: score += 0.3 except aiodns.error.DNSError: score += 0.8 return min(score, 1.0)