richardschneider / net-udns

Clients for unicast DNS servers
MIT License
15 stars 6 forks source link
dns-client dns-over-htttps dns-over-tls

net-udns

build status travis build CircleCI Coverage Status Version docs

DNS clients that can fetch more than A and AAAA resource records.

Features

Getting started

Published releases are available on NuGet. To install, run the following command in the Package Manager Console.

PM> Install-Package Makaretu.Dns.Unicast

Usage

Get IP addresses

using Makaretu.Dns;

var dns = new DnsClient();
var addresses = await dns.ResolveAsync("cloudflare-dns.com");
foreach (var a in addresses)
    Console.WriteLine(a.ToString());

Produces the output

104.16.111.25
104.16.112.25
2400:cb00:2048:1::6810:6f19
2400:cb00:2048:1::6810:7019

Get all the TXT strings

using Makaretu.Dns;

var dns = new DnsClient();
var response = await dns.QueryAsync("ipfs.io", DnsType.TXT);
var strings = response.Answers
    .OfType<TXTRecord>()
    .SelectMany(txt => txt.Strings);
foreach (var s in strings)
    Console.WriteLine(s);

Produces the output

dnslink=/ipfs/QmYNQJoKGNHTpPxCBPh9KkDpaExgd2duMa3aF6ytMpHdao

License

Copyright © 2018 Richard Schneider (makaretu@gmail.com)

The package is licensed under the MIT license. Refer to the LICENSE file for more information.