#dns #dns-records #dnssec #dns-resolver #dig #named #bind

hickory-client

Hickory DNS is a safe and secure DNS library. This is the Client library with DNSSEC support. DNSSEC with NSEC validation for negative records, is complete. The client supports dynamic DNS with SIG0 authenticated requests, implementing easy to use high level functions. Hickory DNS is based on the Tokio and Futures libraries, which means it should be easily integrated into other software that also use those libraries.

8 releases

0.25.0-alpha.4 Nov 28, 2024
0.25.0-alpha.3 Nov 8, 2024
0.25.0-alpha.2 Aug 6, 2024
0.25.0-alpha.1 Jun 16, 2024
0.1.0 Sep 26, 2023

#67 in Network programming

Download history 7347/week @ 2024-08-23 6302/week @ 2024-08-30 4861/week @ 2024-09-06 5059/week @ 2024-09-13 7389/week @ 2024-09-20 5531/week @ 2024-09-27 7364/week @ 2024-10-04 7525/week @ 2024-10-11 4687/week @ 2024-10-18 6869/week @ 2024-10-25 6497/week @ 2024-11-01 8593/week @ 2024-11-08 8893/week @ 2024-11-15 8248/week @ 2024-11-22 9197/week @ 2024-11-29 9639/week @ 2024-12-06

37,842 downloads per month
Used in 25 crates (18 directly)

MIT/Apache

2MB
32K SLoC

Overview

Hickory DNS is a library which implements the DNS protocol and client side functions.

This library contains basic implementations for DNS record serialization, and communication. It is capable of performing query, update, and notify operations. update has been proven to be compatible with BIND9 and SIG0 signed records for updates. It is built on top of the tokio async-io project, this allows it to be integrated into other systems using the tokio and futures libraries. The Hickory DNS project contains other libraries for DNS: a resolver library for lookups, a server library for hosting zones, and variations on the TLS implementation over rustls and native-tls.

NOTICE This project was rebranded from Trust-DNS to Hickory DNS and has been moved to the https://github.com/hickory-dns/hickory-dns organization and repo, this crate/binary has been moved to hickory-client, from 0.24 and onward, for prior versions see trust-dns-client.

Features

The client is capable of DNSSEC validation as well as offering higher order functions for performing DNS operations:

Example

use std::net::{Ipv4Addr, SocketAddr};
use std::str::FromStr;
use hickory_client::client::{Client, ClientHandle};
use hickory_client::proto::rr::{rdata::A, DNSClass, Name, RData, Record, RecordType};
use hickory_client::proto::runtime::TokioRuntimeProvider;
use hickory_client::proto::udp::UdpClientStream;
use hickory_client::proto::xfer::DnsResponse;

let address = SocketAddr::from(([8, 8, 8, 8], 53));
let conn = UdpClientStream::builder(address, TokioRuntimeProvider::default()).build();
let (mut client, bg) = Client::connect(conn).await.unwrap();
tokio::spawn(bg);

// Specify the name, note the final '.' which specifies it's an FQDN
let name = Name::from_str("www.example.com.").unwrap();

// NOTE: see 'Setup a connection' example above
// Send the query and get a message response, see RecordType for all supported options
let response: DnsResponse = client
    .query(name, DNSClass::IN, RecordType::A)
    .await
    .unwrap();

// Messages are the packets sent between client and server in DNS, DnsResonse's can be
//  dereferenced to a Message. There are many fields to a Message, It's beyond the scope
//  of these examples to explain them. See hickory_dns::op::message::Message for more details.
//  generally we will be interested in the Message::answers
let answers: &[Record] = response.answers();

// Records are generic objects which can contain any data.
//  In order to access it we need to first check what type of record it is
//  In this case we are interested in A, IPv4 address
if let RData::A(A(ref ip)) = answers[0].data() {
    assert_eq!(*ip, Ipv4Addr::new(93, 184, 215, 14))
} else {
    panic!("unexpected result")
}

DNS-over-TLS and DNS-over-HTTPS

DoT and DoH are supported. This is accomplished through the use of one of native-tls, openssl, or rustls (only rustls is currently supported for DoH).

To use DoT or DoH with the Client, construct it with TlsClientStream or HttpsClientStream. Client authentication/mTLS is currently not supported, there are some issues still being worked on. TLS is useful for Server authentication and connection privacy.

To enable DoT, one of the features dns-over-native-tls, dns-over-openssl, or dns-over-rustls must be enabled. dns-over-https-rustls is used for DoH.

DNSSEC status

The current root key is bundled into the system, and used by default. This gives validation of DNSKEY and DS records back to the root. NSEC and NSEC3 are implemented.

Zones will be automatically resigned on any record updates via dynamic DNS. To enable DNSSEC, one of the features dnssec-openssl or dnssec-ring must be enabled.

Minimum Rust Version

The current minimum rustc version for this project is 1.70

Versioning

Hickory DNS does it's best job to follow semver. Hickory DNS will be promoted to 1.0 upon stabilization of the publicly exposed APIs. This does not mean that Hickory DNS will necessarily break on upgrades between 0.x updates. Whenever possible, old APIs will be deprecated with notes on what replaced those deprecations. Hickory DNS will make a best effort to never break software which depends on it due to API changes, though this can not be guaranteed. Deprecated interfaces will be maintained for at minimum one major release after that in which they were deprecated (where possible), with the exception of the upgrade to 1.0 where all deprecated interfaces will be planned to be removed.

Dependencies

~6–20MB
~297K SLoC