Crates.io | drasil-dns |
lib.rs | drasil-dns |
version | 0.2.1 |
source | src |
created_at | 2024-11-30 20:39:15.052689 |
updated_at | 2024-12-10 16:55:36.577055 |
description | Rust crate to easily serialize and deserialize DNS packets |
homepage | |
repository | https://github.com/ShardulNalegave/drasil |
max_upload_size | |
id | 1466967 |
size | 67,146 |
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.
Add drasil-dns to your project by including it in your Cargo.toml
file:
[dependencies]
drasil-dns = "x" # Replace with the latest version
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),
}
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();
This project is licensed under the MIT License. See the LICENSE
file for details.