Crate toluol_proto

Crate toluol_proto 

Source
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
DNSSEC validation.
error
Custom error type definitions.
name
Definition and implementation of the Name type.
rdata
RDATA type definitions.

Macros§

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

Structs§

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

Enums§

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