SHA256
Updated and condensed.
This commit is contained in:
+17
-31
@@ -83,10 +83,11 @@ builtin_providers = [] # list of provider keys used
|
|||||||
# Resolve builtin nameservers to actual IPs
|
# Resolve builtin nameservers to actual IPs
|
||||||
if args.ns_builtin:
|
if args.ns_builtin:
|
||||||
# Handle 'all' special case
|
# Handle 'all' special case
|
||||||
if "all" in [p.lower() for p in args.ns_builtin]:
|
builtin_providers = (
|
||||||
builtin_providers = list(builtin_nameservers.keys())
|
list(builtin_nameservers.keys())
|
||||||
else:
|
if "all" in [p.lower() for p in args.ns_builtin]
|
||||||
builtin_providers = [p.lower() for p in args.ns_builtin]
|
else [p.lower() for p in args.ns_builtin]
|
||||||
|
)
|
||||||
|
|
||||||
for provider in builtin_providers:
|
for provider in builtin_providers:
|
||||||
if provider not in builtin_nameservers:
|
if provider not in builtin_nameservers:
|
||||||
@@ -298,27 +299,10 @@ def perform_query(full_domain, ns, record_type, timeout):
|
|||||||
rcode_name = rcode.to_text(response_rcode)
|
rcode_name = rcode.to_text(response_rcode)
|
||||||
return (full_domain, ns, f"RCODE: {rcode_name}", protocol_used)
|
return (full_domain, ns, f"RCODE: {rcode_name}", protocol_used)
|
||||||
|
|
||||||
# Check answer section first
|
# Check answer section first, then additional, then authority
|
||||||
answers = r.answer
|
for section in (r.answer, r.additional, r.authority):
|
||||||
if answers:
|
if section:
|
||||||
for rrset in answers:
|
for rrset in section:
|
||||||
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:
|
for item in rrset:
|
||||||
results.append(str(item))
|
results.append(str(item))
|
||||||
if results:
|
if results:
|
||||||
@@ -401,10 +385,11 @@ for full_domain in full_domains:
|
|||||||
results, protocol_used = results_map[(full_domain, ns)]
|
results, protocol_used = results_map[(full_domain, ns)]
|
||||||
# Create entry with result and protocol
|
# Create entry with result and protocol
|
||||||
entry = {}
|
entry = {}
|
||||||
# Handle error/timeout/rcode cases (strings)
|
# Handle error/timeout/rcode cases (strings) vs list of results
|
||||||
if isinstance(results, str):
|
match results:
|
||||||
|
case str():
|
||||||
entry["result"] = results
|
entry["result"] = results
|
||||||
else:
|
case list():
|
||||||
results = sorted(results)
|
results = sorted(results)
|
||||||
# Store as single value if only one result, otherwise as array
|
# Store as single value if only one result, otherwise as array
|
||||||
entry["result"] = results[0] if len(results) == 1 else results
|
entry["result"] = results[0] if len(results) == 1 else results
|
||||||
@@ -438,10 +423,11 @@ for full_domain in full_domains:
|
|||||||
results, protocol_used = results_map[(full_domain, ns)]
|
results, protocol_used = results_map[(full_domain, ns)]
|
||||||
# Create entry with result and protocol
|
# Create entry with result and protocol
|
||||||
entry = {}
|
entry = {}
|
||||||
# Handle error/timeout/rcode cases (strings)
|
# Handle error/timeout/rcode cases (strings) vs list of results
|
||||||
if isinstance(results, str):
|
match results:
|
||||||
|
case str():
|
||||||
entry["result"] = results
|
entry["result"] = results
|
||||||
else:
|
case list():
|
||||||
results = sorted(results)
|
results = sorted(results)
|
||||||
# Store as single value if only one result, otherwise as array
|
# Store as single value if only one result, otherwise as array
|
||||||
entry["result"] = results[0] if len(results) == 1 else results
|
entry["result"] = results[0] if len(results) == 1 else results
|
||||||
|
|||||||
Reference in New Issue
Block a user