Swiftpack.co - Package - seznam/swift-resolver

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: 1

Dependencies

Used By

Total: 0