Updated and condensed.

This commit is contained in:
Discsearcher
2026-09-10 15:06:42 -04:00
parent 9b5057dd90
commit 6c0f10c629
+29 -43
View File
@@ -83,10 +83,11 @@ builtin_providers = [] # list of provider keys used
# Resolve builtin nameservers to actual IPs
if args.ns_builtin:
# Handle 'all' special case
if "all" in [p.lower() for p in args.ns_builtin]:
builtin_providers = list(builtin_nameservers.keys())
else:
builtin_providers = [p.lower() for p in args.ns_builtin]
builtin_providers = (
list(builtin_nameservers.keys())
if "all" in [p.lower() for p in args.ns_builtin]
else [p.lower() for p in args.ns_builtin]
)
for provider in builtin_providers:
if provider not in builtin_nameservers:
@@ -298,31 +299,14 @@ def perform_query(full_domain, ns, record_type, timeout):
rcode_name = rcode.to_text(response_rcode)
return (full_domain, ns, f"RCODE: {rcode_name}", protocol_used)
# Check answer section first
answers = r.answer
if answers:
for rrset in answers:
for item in rrset:
results.append(str(item))
return (full_domain, ns, results, protocol_used)
# If no answer, check additional section (some servers put records there)
additional = r.additional
if additional:
for rrset in additional:
for item in rrset:
results.append(str(item))
if results:
return (full_domain, ns, results, protocol_used)
# If still no results, check authority section
authority = r.authority
if authority:
for rrset in authority:
for item in rrset:
results.append(str(item))
if results:
return (full_domain, ns, results, protocol_used)
# Check answer section first, then additional, then authority
for section in (r.answer, r.additional, r.authority):
if section:
for rrset in section:
for item in rrset:
results.append(str(item))
if results:
return (full_domain, ns, results, protocol_used)
# Truly no records found
return (full_domain, ns, "NO RECORDS", protocol_used)
@@ -401,13 +385,14 @@ for full_domain in full_domains:
results, protocol_used = results_map[(full_domain, ns)]
# Create entry with result and protocol
entry = {}
# Handle error/timeout/rcode cases (strings)
if isinstance(results, str):
entry["result"] = results
else:
results = sorted(results)
# Store as single value if only one result, otherwise as array
entry["result"] = results[0] if len(results) == 1 else results
# Handle error/timeout/rcode cases (strings) vs list of results
match results:
case str():
entry["result"] = results
case list():
results = sorted(results)
# Store as single value if only one result, otherwise as array
entry["result"] = results[0] if len(results) == 1 else results
if protocol_used:
entry["protocol"] = protocol_used
output["records"][full_domain]["results"][provider][ns] = entry
@@ -438,13 +423,14 @@ for full_domain in full_domains:
results, protocol_used = results_map[(full_domain, ns)]
# Create entry with result and protocol
entry = {}
# Handle error/timeout/rcode cases (strings)
if isinstance(results, str):
entry["result"] = results
else:
results = sorted(results)
# Store as single value if only one result, otherwise as array
entry["result"] = results[0] if len(results) == 1 else results
# Handle error/timeout/rcode cases (strings) vs list of results
match results:
case str():
entry["result"] = results
case list():
results = sorted(results)
# Store as single value if only one result, otherwise as array
entry["result"] = results[0] if len(results) == 1 else results
if protocol_used:
entry["protocol"] = protocol_used
output["records"][full_domain]["results"][ns] = entry