mirror of
https://github.com/EmilHernvall/dnsguide.git
synced 2024-12-23 01:24:17 +07:00
rustfmt examples/*.rs
This commit is contained in:
parent
abd3bb9525
commit
24a949c4d4
@ -300,10 +300,7 @@ pub struct DnsQuestion {
|
|||||||
|
|
||||||
impl DnsQuestion {
|
impl DnsQuestion {
|
||||||
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
||||||
DnsQuestion {
|
DnsQuestion { name, qtype }
|
||||||
name,
|
|
||||||
qtype,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
||||||
@ -352,11 +349,7 @@ impl DnsRecord {
|
|||||||
((raw_addr >> 0) & 0xFF) as u8,
|
((raw_addr >> 0) & 0xFF) as u8,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::A {
|
Ok(DnsRecord::A { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::UNKNOWN(_) => {
|
QueryType::UNKNOWN(_) => {
|
||||||
buffer.step(data_len as usize)?;
|
buffer.step(data_len as usize)?;
|
||||||
|
@ -336,10 +336,7 @@ pub struct DnsQuestion {
|
|||||||
|
|
||||||
impl DnsQuestion {
|
impl DnsQuestion {
|
||||||
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
||||||
DnsQuestion {
|
DnsQuestion { name, qtype }
|
||||||
name,
|
|
||||||
qtype,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
||||||
@ -398,11 +395,7 @@ impl DnsRecord {
|
|||||||
((raw_addr >> 0) & 0xFF) as u8,
|
((raw_addr >> 0) & 0xFF) as u8,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::A {
|
Ok(DnsRecord::A { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::UNKNOWN(_) => {
|
QueryType::UNKNOWN(_) => {
|
||||||
buffer.step(data_len as usize)?;
|
buffer.step(data_len as usize)?;
|
||||||
|
@ -361,10 +361,7 @@ pub struct DnsQuestion {
|
|||||||
|
|
||||||
impl DnsQuestion {
|
impl DnsQuestion {
|
||||||
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
||||||
DnsQuestion {
|
DnsQuestion { name, qtype }
|
||||||
name,
|
|
||||||
qtype,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
||||||
@ -444,11 +441,7 @@ impl DnsRecord {
|
|||||||
((raw_addr >> 0) & 0xFF) as u8,
|
((raw_addr >> 0) & 0xFF) as u8,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::A {
|
Ok(DnsRecord::A { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::AAAA => {
|
QueryType::AAAA => {
|
||||||
let raw_addr1 = buffer.read_u32()?;
|
let raw_addr1 = buffer.read_u32()?;
|
||||||
@ -466,11 +459,7 @@ impl DnsRecord {
|
|||||||
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::AAAA {
|
Ok(DnsRecord::AAAA { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::NS => {
|
QueryType::NS => {
|
||||||
let mut ns = String::new();
|
let mut ns = String::new();
|
||||||
|
@ -361,10 +361,7 @@ pub struct DnsQuestion {
|
|||||||
|
|
||||||
impl DnsQuestion {
|
impl DnsQuestion {
|
||||||
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
||||||
DnsQuestion {
|
DnsQuestion { name, qtype }
|
||||||
name,
|
|
||||||
qtype,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
||||||
@ -444,11 +441,7 @@ impl DnsRecord {
|
|||||||
((raw_addr >> 0) & 0xFF) as u8,
|
((raw_addr >> 0) & 0xFF) as u8,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::A {
|
Ok(DnsRecord::A { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::AAAA => {
|
QueryType::AAAA => {
|
||||||
let raw_addr1 = buffer.read_u32()?;
|
let raw_addr1 = buffer.read_u32()?;
|
||||||
@ -466,11 +459,7 @@ impl DnsRecord {
|
|||||||
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::AAAA {
|
Ok(DnsRecord::AAAA { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::NS => {
|
QueryType::NS => {
|
||||||
let mut ns = String::new();
|
let mut ns = String::new();
|
||||||
@ -793,7 +782,7 @@ fn main() -> Result<()> {
|
|||||||
// requests is initiated.
|
// requests is initiated.
|
||||||
loop {
|
loop {
|
||||||
match handle_query(&socket) {
|
match handle_query(&socket) {
|
||||||
Ok(_) => {},
|
Ok(_) => {}
|
||||||
Err(e) => eprintln!("An error occurred: {}", e),
|
Err(e) => eprintln!("An error occurred: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,10 +361,7 @@ pub struct DnsQuestion {
|
|||||||
|
|
||||||
impl DnsQuestion {
|
impl DnsQuestion {
|
||||||
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
pub fn new(name: String, qtype: QueryType) -> DnsQuestion {
|
||||||
DnsQuestion {
|
DnsQuestion { name, qtype }
|
||||||
name,
|
|
||||||
qtype,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
pub fn read(&mut self, buffer: &mut BytePacketBuffer) -> Result<()> {
|
||||||
@ -444,11 +441,7 @@ impl DnsRecord {
|
|||||||
((raw_addr >> 0) & 0xFF) as u8,
|
((raw_addr >> 0) & 0xFF) as u8,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::A {
|
Ok(DnsRecord::A { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::AAAA => {
|
QueryType::AAAA => {
|
||||||
let raw_addr1 = buffer.read_u32()?;
|
let raw_addr1 = buffer.read_u32()?;
|
||||||
@ -466,11 +459,7 @@ impl DnsRecord {
|
|||||||
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
((raw_addr4 >> 0) & 0xFFFF) as u16,
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(DnsRecord::AAAA {
|
Ok(DnsRecord::AAAA { domain, addr, ttl })
|
||||||
domain,
|
|
||||||
addr,
|
|
||||||
ttl,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
QueryType::NS => {
|
QueryType::NS => {
|
||||||
let mut ns = String::new();
|
let mut ns = String::new();
|
||||||
@ -886,7 +875,7 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
match handle_query(&socket) {
|
match handle_query(&socket) {
|
||||||
Ok(_) => {},
|
Ok(_) => {}
|
||||||
Err(e) => eprintln!("An error occurred: {}", e),
|
Err(e) => eprintln!("An error occurred: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user