Swiftpack.co -  seznam/swift-resolver as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
seznam/swift-resolver
DNS resolver for Swift
.package(url: "https://github.com/seznam/swift-resolver.git", from: "0.3.0")

macOS Linux Apache 2 Build Status

Resolver

Let your swift application query DNS easily.

Usage

Get hostname of the system:

import Resolver

if let hostname = Resolver.getHostname() {
	print("my hostname is '\(hostname)'")
} else {
	print("failed to get my hostname")
}

Get nameservers used by the system:

import Resolver

let ns = Resolver.getNameserver()

if ns.isEmpty {
	print("failed to get nameservers")
} else {
	print("nameservers used by this system: \(ns)")
}

Query DNS server using default nameservers and custom timeout:

import Resolver

do {
	let resolver = Resolver(timeout: 3)
	let answer = try resolver.resolve("www.seznam.cz")
	print(answer)
} catch ResolverError.error(let detail) {
	print(detail)
}

Discover services using custom nameservers:

import Resolver

do {
	let resolver = Resolver(nameserver: [ "77.75.74.80", "77.75.75.230" ])
	let answer = try resolver.discover("_autodiscover._tcp.email.cz")
	print(answer)
} catch ResolverError.error(let detail) {
	print(detail)
}

Credits

Written by Daniel Fojt, copyright Seznam.cz, licensed under the terms of the Apache License 2.0.

GitHub

link
Stars: 3
Last commit: 1 year ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

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