apple / apple/swift-async-dns-resolver

Lookups on dual-stacked networks fail

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

Description

Lookups on dual-stacked networks fail and throw `connection refused: (CAresError(code: 11))`. The error is spurious; it's not a "connection refused" by TCP/UDP. Both the v4 and v6 resolvers work by `host` or `host -T`, and indeed, hard-coding either resolver address (v4 or v6) from /etc/resolv.conf into `resOptions.servers` gets it working. Hard-coding `resOptions.servers = ["2001:4860:4860::6464", "8.8.8.8"]` also gets it working. Hard-coding a DNS (even Google's) in public releases is a really awful hack, but appears to be the only work-around.

Test code is something like this:
```
do {
var resOptions = CAresDNSResolver.Options.default
resOptions.timeoutMillis = 10_000
//resOptions.servers = ["2001:4860:4860::6464", "8.8.8.8"] // add this hack to make it work
let resolver = try! AsyncDNSResolver(options: resOptions)
records = try await resolver.querySRV(name: srvName)
} catch let error {
print("AsyncDNSResolver error: \(error)")
throw error
}
```

Some investigation suggests that updating the underlying ca-res library might fix this.

Contributor guide

Open the contributing guide

Research direction

Start at CAresDNSResolver.Options.default and the AsyncDNSResolver(options:) initialization shown in the report, then reproduce the querySRV failure on a dual-stacked network without hard-coded servers. Check whether the underlying c-ares dependency is involved; done means dual-stack lookups succeed and no spurious connection-refused error is reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.