Skip to content

richardschneider/net-udns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

net-udns

build status travis build CircleCI Coverage Status Version docs

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

Features

  • DnsClient for a standard unicast DNS server
    • Initially uses UDP
    • Fallbacks to TCP if no UDP response or the response is truncated
  • DohClient for a DNS over HTTPS (DOH) server
  • DotClient for a DNS over TLS (DOT) server
    • Padding of requests
    • TCP Keepalive
  • Supports asynchronous I/O
  • Supports cancellation
  • Supports IPv6 and IPv4 platforms
  • Targets .Net Framework 4.6 an .NET Standard 1.4 and 2.0
  • CI on Circle (Debian GNU/Linux), Travis (Ubuntu Trusty and OSX) and AppVeyor (Windows Server 2016)

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.