/swift-async-dns-resolver

A Swift library for asynchronous DNS requests, wrapping c-ares with Swift-friendly APIs and data structures.

Primary LanguageSwiftApache License 2.0Apache-2.0

Swift Asynchronous DNS Resolver

A Swift library for asynchronous DNS queries.

Overview

This library wraps around the dnssd framework and the c-ares C library with Swift-friendly APIs and data structures.

Usage

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"),
],

Using the 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
...