#DNS #BIND #dig #named #dnssec

trust-dns

Trust-DNS is a safe and secure DNS library. This is the Client library with DNSec 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 funtions. Trust-DNS is based on the Tokio and Futures libraries, which means it should be easily integrated into other software that also use those libraries.

42 releases

0.16.1 May 29, 2019
0.16.0-alpha.2 Jan 27, 2019
0.15.0 Nov 1, 2018
0.15.0-alpha.1 Jul 22, 2018
0.4.0 Nov 9, 2015

#10 in Network programming

Download history 572/week @ 2019-03-26 519/week @ 2019-04-02 617/week @ 2019-04-09 359/week @ 2019-04-16 512/week @ 2019-04-23 472/week @ 2019-04-30 398/week @ 2019-05-07 422/week @ 2019-05-14 410/week @ 2019-05-21 352/week @ 2019-05-28 280/week @ 2019-06-04 473/week @ 2019-06-11 550/week @ 2019-06-18 710/week @ 2019-06-25 1256/week @ 2019-07-02

1,902 downloads per month
Used in 16 crates (14 directly)

MIT/Apache

1MB
19K SLoC

Overview

Trust-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 Trust-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.

Features

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

Example

use std::net::Ipv4Addr;
use std::str::FromStr;
use trust_dns::client::{Client, SyncClient};
use trust_dns::udp::UdpClientConnection;
use trust_dns::op::DnsResponse;
use trust_dns::rr::{DNSClass, Name, RData, Record, RecordType};

let address = "8.8.8.8:53".parse().unwrap();
let conn = UdpClientConnection::new(address).unwrap();
let client = SyncClient::new(conn);

// 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).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 trust_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(ref ip) = answers[0].rdata() {
    assert_eq!(*ip, Ipv4Addr::new(93, 184, 216, 34))
} else {
    assert!(false, "unexpected result")
}

Versioning

Trust-DNS does it's best job to follow semver. Trust-DNS will be promoted to 1.0 upon stabilization of the publicly exposed APIs. This does not mean that Trust-DNS will necessarily break on upgrades between 0.x updates. Whenever possible, old APIs will be deprecated with notes on what replaced those deprecations. Trust-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

~9MB
~184K SLoC