Skip to content

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

License

Notifications You must be signed in to change notification settings

apple/swift-async-dns-resolver

Repository files navigation

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:/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 = try AsyncDNSResolver()

// Run a query
let aRecords = try await resolver.queryA(name: "apple.com")

// Process the `ARecord`s
...