import base64 import json import urllib.request HOSTS = ["lucasjow.us.ci", "snip.edgeoneai.cc.cd", "www.volumeroot.com", "server5.9966338.xyz"] def q(name, rtype="HTTPS"): url = f"https://cloudflare-dns.com/dns-query?name={name}&type={rtype}" req = urllib.request.Request(url, headers={"accept": "application/dns-json"}) with urllib.request.urlopen(req, timeout=15) as r: return json.load(r) for host in HOSTS: try: d = q(host) ech = None ips = [] for a in d.get("Answer", []): data = a.get("data", "") if a.get("type") == 1: ips.append(data) for tok in data.split(): if tok.startswith("ech="): ech = tok[4:] if ech: pad = "=" * (-len(ech) % 4) raw = base64.urlsafe_b64decode(ech + pad) print(f"{host}\tA={','.join(ips) or '-'}\tech_b64={base64.b64encode(raw).decode()}") else: print(f"{host}\tA={','.join(ips) or '-'}\tech=NONE") except Exception as exc: # noqa: BLE001 print(f"{host}\tERROR {exc}")