Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read Authority field in Cloudflare/Google DNS response #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stevefrench39
Copy link

@stevefrench39 stevefrench39 commented Jul 8, 2024

For some DNS queries, such as type=NS when name=subdomain.example.com, the response from Cloudflare/Google contains an Authority field instead of Answer.

This change reads the Authority field if present in order to fix a bug with getAllDNSRecords("subdomain.example.com", { resolver: "cloudflare-dns" }). Currently, instead of returning the records associated with the subdomain, it incorrectly returns an empty array because it does not read the Authority field in the NS records response. As a result, nsRecords.length = 0 which fails the nsRecords.length check here, and no requests for additional records are made.

curl --location 'https://dns.google/resolve?name=subdomain.example.com&type=NS&cd=1' \
--header 'accept: application/dns-json'

{
    "Status": 3,
    "TC": false,
    "RD": true,
    "RA": true,
    "AD": false,
    "CD": true,
    "Question": [
        {
            "name": "subdomain.example.com.",
            "type": 2
        }
    ],
    "Authority": [
        {
            "name": "example.com.",
            "type": 6,
            "TTL": 1800,
            "data": "ns.icann.org. noc.dns.icann.org. 2024041842 7200 3600 1209600 3600"
        }
    ],
    "Comment": "Response from 199.43.135.53."
}

For some DNS queries, such as type=NS when name=subdomain.example.com, the response contains an `Authority` field instead of `Answer`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant