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

DNSSD based queries fail to provide TTL #39

Open
gmilos opened this issue Jun 4, 2024 · 1 comment
Open

DNSSD based queries fail to provide TTL #39

gmilos opened this issue Jun 4, 2024 · 1 comment

Comments

@gmilos
Copy link

gmilos commented Jun 4, 2024

On macOS (where DNSSD is being used by default), queries such as:

let resolver = try AsyncDNSResolver()
let out = try await resolver.queryAAAA(name: "iadsdk.apple.com.akadns.net")
print("\(out)")

fail to provide the TTL:

[AAAARecord(address=2a02:26f0:5d00:f91::12c5, ttl=), AAAARecord(address=2a02:26f0:5d00:f9b::12c5, ttl=)]

Despite the fact TTL is certainly available:

$ dig AAAA iadsdk.apple.com.akadns.net
...
e4805.dsca.akamaiedge.net. 3	IN	AAAA	2a02:26f0:5d00:f9b::12c5
                           ↑
                          TTL
...

The TTL is available, if the c-ares underlying implementation is used:

let resolver = try AsyncDNSResolver(CAresDNSResolver())
let out = try await resolver.queryAAAA(name: "e4805.dsca.akamaiedge.net")
print("\(out)") 

results in:

[AAAARecord(address=2a02:26f0:5d00:f91::12c5, ttl=13), AAAARecord(address=2a02:26f0:5d00:f9b::12c5, ttl=13)]

Tested on: https://github.com/apple/swift-async-dns-resolver/releases/tag/0.4.0

@danieleggert
Copy link

  1. Generally, all result records should have TTL info, not just A / AAAA records. E.g. the MX record currently has no TTL, even though it’s in the DNS response.

  2. I’m not entirely sure, but it seems odd to have the TTL be optional. Don’t the RFCs make TTL a mandatory part of any DNS response?

  3. Generally, from an API perspective, it is odd to have the TTL be part of the record type (e.g. ARecord) since in the DNS world, the TTL is part of the response, but not the record. It seems like it would have been a better design to have something like

Response<A> {
    var record: A
    var ttl: Int
}

or similar, where A would then be ARecord, MXRecord, etc. Just a thought.

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

No branches or pull requests

2 participants