Expand description

toluol-proto provides the definition of the DNS protocol’s data types as well as the means to de-/serialize them from/to the wire format. In simpler terms, you can construct, encode, and decode DNS queries and responses with it.

It is used as the backend for toluol, a DNS client that aims to replace dig, but you can use this library on its own as well. It is possible to compile it to WASM, so you can even make DNS queries from the browser with it (using DNS over HTTPS).

Basic usage example

use toluol_proto::{EdnsConfig, HeaderFlags, Message, Name, Opcode, RecordType};

let flags = HeaderFlags { aa: false, tc: false, rd: true, ra: false, ad: true, cd: true };
let msg = Message::new_query(
    Name::from_ascii("example.com").unwrap(),
    RecordType::A,
    Opcode::QUERY,
    flags,
    Some(EdnsConfig {
        do_flag: false,
        bufsize: 4096,
        client_cookie: None,
    }),
).unwrap();
let _encoded = msg.encode().unwrap();

If you’re also looking for utilities to actually send and receive DNS queries and responses, please take a look at toluol.

Usage note

You can construct most structs directly, without using any new() method. In some cases, this can lead to inconsistencies, e.g. manually creating a Message where the record counts in the header don’t match the actual number of records.

In these cases, you should prefer using the appropriate constructor of the struct (if there is none, please file a bug). However, this library does not force you to do so, so that you have as much freedom using it as possible. It won’t stop you if you really want to create inconsistent messages, for whatever reason.

Re-exports

pub use name::Name;
pub use rdata::Rdata;

Modules

DNSSEC validation.
Custom error type definitions.
Definition and implementation of the Name type.
RDATA type definitions.

Macros

Match on every Rdata variant and execute a block for it.

Structs

EDNS parameters.
Represents a DNS header.
Represents the flags of a Header.
Represents a DNS message.
The NONOPT variant of Record.
The OPT variant of Record.
Represents a DNS question, i.e. an entry in the question section of a DNS message.

Enums

Represents a DNS CLASS.
Represents a DNS OpCode.
Flags for an OptRecord.
Represents a DNS RCODE, including those introduced by EDNS.
Represents a DNS record, i.e. an entry in the answer, authority or additional section of a DNS message.
Represents a DNS TYPE.