Swiftpack.co - orlandos-nl/DNSClient as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by orlandos-nl.
orlandos-nl/DNSClient 2.3.2
A DNS Resolver in Swift
⭐️ 32
🕓 2 weeks ago
.package(url: "https://github.com/orlandos-nl/DNSClient.git", from: "2.3.2")


Async DNS resolution, with all the DNS features you need!

Join our Discord for any questions and friendly banter.

Installation 💥

Add the package:

.package(url: "https://github.com/orlandos-nl/DNSClient.git", from: "2.0.0"),

And to your target:

.product(name: "DNSClient", package: "DNSClient"),

Usage 🤯

Connect to your default DNS Server:

let client = try DNSClient.connect(on: loop).wait()

Connect to a specific DNS Server:

let googleDNS = SocketAddress(ipAddress: "", port: 53)
let client = try DNSClient.connect(on: loop, config: [googleDNS]).wait()

Resolve SRV Records:

let records = try client.sendQuery(forHost: "example.com", type: .srv).wait()

Resolve TXT Records:

let records = try client.sendQuery(forHost: "example.com", type: .txt).wait()

Need I say more?


The DNS Client doesn't retain itself during requests. This means that you cannot do the following:

DNSClient.connect(on: request.eventLoop).flatMap { client in
    // client.doQueryStuff()

The client will deallocate itself, resulting in a timeout. Make sure that the client is strongly referenced, either until all results are in or by setting it on a shared context. In Vapor, that can be the request's storage container. On other services, you could consider a global, ThreadSpecificVariable or a property on your class.

Featured In 🛍


Stars: 32
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

5 weeks ago

Fix iOS compilation

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics