A Swift library for asynchronous DNS queries.
This library wraps around the dnssd framework and the c-ares C library with Swift-friendly APIs and data structures.
Add the package dependency in your Package.swift
:
.package(
url: "https://github.com/apple/swift-async-dns-resolver",
.upToNextMajor(from: "0.1.0")
),
Next, in your target, add AsyncDNSResolver
to your dependencies:
.target(name: "MyTarget", dependencies: [
.product(name: "AsyncDNSResolver", package: "swift-async-dns-resolver"),
],
// import the package
import AsyncDNSResolver
// Initialize a resolver
let resolver = AsyncDNSResolver()
// Run a query
let aRecords = try await resolver.queryA(name: "apple.com")
// Process the `ARecord`s
...