-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.rs
31 lines (27 loc) · 788 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::error::Error;
// use crate::File;
use std::fs::File;
use crate::protocol::byte_packet_buffer::BytePacketBuffer;
use crate::protocol::dnspacket::DnsPacket;
use std::io::Read;
#[allow(dead_code)]
fn test_with_response_packet() -> Result<(), Box<dyn Error>> {
let mut f = File::open("response_packet.txt")?;
let mut buffer = BytePacketBuffer::new();
f.read(&mut buffer.buf)?;
let packet = DnsPacket::from_buffer(&mut buffer)?;
println!("{:#?}", packet.header);
for q in packet.questions {
println!("{:#?}", q);
}
for rec in packet.answers {
println!("{:#?}", rec);
}
for rec in packet.authorities {
println!("{:#?}", rec);
}
for rec in packet.resources {
println!("{:#?}", rec);
}
Ok(())
}