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§
Modules§
- dnssec
- DNSSEC validation.
- error
- Custom error type definitions.
- name
- Definition and implementation of the
Nametype. - rdata
- RDATA type definitions.
Macros§
- match_
rdata - Match on every
Rdatavariant and execute a block for it.
Structs§
- Edns
Config - EDNS parameters.
- Header
- Represents a DNS header.
- Header
Flags - Represents the flags of a
Header. - Message
- Represents a DNS message.
- NonOpt
Record - The
NONOPTvariant ofRecord. - OptRecord
- The
OPTvariant ofRecord. - Question
- Represents a DNS question, i.e. an entry in the question section of a DNS message.