4 releases
0.2.1 | Dec 10, 2024 |
---|---|
0.2.0 | Dec 10, 2024 |
0.1.1 | Dec 1, 2024 |
0.1.0 | Nov 30, 2024 |
#1565 in Network programming
507 downloads per month
67KB
2K
SLoC
drasil-dns
drasil-dns is a Rust-based DNS library designed for parsing and handling DNS packets with an emphasis on correctness. It supports modern DNS features like EDNS (Extension Mechanisms for DNS) and is able to parse DNSSEC (Domain Name System Security Extensions) related data.
Features
- EDNS(0):
- DNSSEC:
- Error Types: The library provides its own error-types to give useful context in case of errors.
Installation
Add drasil-dns to your project by including it in your Cargo.toml
file:
[dependencies]
drasil-dns = "x" # Replace with the latest version
Usage
Parsing a DNS Packet
use drasil_dns::{Packet, DrasilDNSError};
let data: &[u8] = &[ ... ]; // Packet data
let res: Result<Packet, DrasilDNSError> = Packet::parse(data);
match res {
Err(e) => eprintln!("Failed to parse packet: {:?}", e), // Handle errors
Ok(packet) => println!("{:#?}", packet),
}
Building a new DNS Packet
use drasil_dns::PacketBuilder;
// Create packets using the builder utility
let builder: PacketBuilder = PacketBuilder::new(5)
.with_request_kind(RequestKind::Query)
.recursion_desired()
.add_question(Question {
name: vec!["google".into(), "com".into()],
record_type: RecordType::A,
record_class: RecordClass::IN,
})
.build();
License
This project is licensed under the MIT License. See the LICENSE
file for details.
Dependencies
~250–700KB
~16K SLoC