apple / apple/swift-async-dns-resolver

Queries for non-existent record type take long time to eventually time out

Open
#37 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Swift
Stars
160
Forks
33
PR merge metrics
No merged PRs in 30d

Description

On macOS, an attempt to resolve name for which the particular record type doesn't exist, results in long (~30s) delay.

For example:

```
AsyncDNSResolver().queryA(name: "some.domain.without.A.record")
```

An investigation showed that adding the additional [`kDNSServiceFlagsReturnIntermediates`](https://developer.apple.com/documentation/dnssd/1823436-anonymous/kdnsserviceflagsreturnintermediates), to the [`DNSServiceQueryRecord` invocation](https://github.com/apple/swift-async-dns-resolver/blob/08c07ff31a745ee5e522ac10132fb4949834d925/Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift#L147) fixes the delay problem. However, now the code has to handle the possibility that `CNAME` gets returned instead of the requested record type, thus requiring it to inspect the `rrclass` and `rrtype` returned to the innermost handler [here](https://github.com/apple/swift-async-dns-resolver/blob/08c07ff31a745ee5e522ac10132fb4949834d925/Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift#L129). If `CNAME` is returned, the desired query should be repeated on that `CNAME`, otherwise an error should be generated.

PRs welcome if someone beats me to the implementation.

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

Contributor guide

Open the contributing guide

Research direction

Start in Sources/AsyncDNSResolver/dnssd/DNSResolver_dnssd.swift, especially the DNSServiceQueryRecord invocation around line 147 and the innermost handler around line 129. Reproduce the non-existent-record query on macOS, then trace how returned rrclass and rrtype are handled. Done means the query no longer waits about 30 seconds, follows a returned CNAME when appropriate, and reports an error otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, swift
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.