diff --git a/dnstp/src/message/message.rs b/dnstp/src/message/message.rs index 663b768..717fa90 100644 --- a/dnstp/src/message/message.rs +++ b/dnstp/src/message/message.rs @@ -1,5 +1,5 @@ use std::net::{Ipv4Addr, SocketAddr}; -use crate::message::{DNSQuestion, DNSHeader, questions_to_bytes, Direction, Opcode, ResponseCode, QType, QClass, ResourceRecord, records_to_bytes, ARdata}; +use crate::message::{DNSQuestion, DNSHeader, questions_to_bytes, Direction, ResponseCode, QType, QClass, ResourceRecord, records_to_bytes, ARdata}; #[derive(Debug)] pub struct DNSMessage { diff --git a/dnstp/src/message/mod.rs b/dnstp/src/message/mod.rs index c3cb4cf..4bebf4d 100644 --- a/dnstp/src/message/mod.rs +++ b/dnstp/src/message/mod.rs @@ -2,9 +2,9 @@ pub mod header; pub mod question; pub mod message; -pub mod answer; +pub mod record; pub use question::{DNSQuestion, QClass, QType, QuestionParseError, questions_to_bytes, questions_from_bytes}; -pub use answer::{ResourceRecord, RawRData, RData, ARdata, AAAARdata, TXTRdata, RecordParseError, records_to_bytes, records_from_bytes}; +pub use record::{ResourceRecord, RawRData, RData, ARdata, AAAARdata, TXTRdata, RecordParseError, records_to_bytes, records_from_bytes}; pub use header::{DNSHeader, Direction, Opcode, ResponseCode, HEADER_SIZE}; pub use message::DNSMessage; \ No newline at end of file diff --git a/dnstp/src/message/question/mod.rs b/dnstp/src/message/question/mod.rs index ba6bbf9..2a42369 100644 --- a/dnstp/src/message/question/mod.rs +++ b/dnstp/src/message/question/mod.rs @@ -2,7 +2,7 @@ mod tests; use urlencoding::decode; -use crate::byte::{push_split_bytes, two_byte_combine, two_byte_extraction, two_byte_split}; +use crate::byte::{push_split_bytes, two_byte_combine}; use crate::string::encode_domain_name; #[repr(u16)] @@ -21,6 +21,7 @@ pub enum QType { RP = 17, AAAA = 28, SRV = 33, + OPT = 41, ANY = 255, } diff --git a/dnstp/src/message/answer/a_rdata.rs b/dnstp/src/message/record/a_rdata.rs similarity index 93% rename from dnstp/src/message/answer/a_rdata.rs rename to dnstp/src/message/record/a_rdata.rs index 6b36abc..a5a9530 100644 --- a/dnstp/src/message/answer/a_rdata.rs +++ b/dnstp/src/message/record/a_rdata.rs @@ -1,6 +1,6 @@ use std::fmt::{Debug, Formatter}; use std::net::Ipv4Addr; -use crate::message::answer::RData; +use crate::message::record::RData; pub struct ARdata { pub rdata: Ipv4Addr diff --git a/dnstp/src/message/answer/aaaa_rdata.rs b/dnstp/src/message/record/aaaa_rdata.rs similarity index 87% rename from dnstp/src/message/answer/aaaa_rdata.rs rename to dnstp/src/message/record/aaaa_rdata.rs index b8ff4cd..2f9da78 100644 --- a/dnstp/src/message/answer/aaaa_rdata.rs +++ b/dnstp/src/message/record/aaaa_rdata.rs @@ -1,6 +1,6 @@ use std::fmt::{Debug, Formatter}; -use std::net::{Ipv4Addr, Ipv6Addr}; -use crate::message::answer::RData; +use std::net::Ipv6Addr; +use crate::message::record::RData; pub struct AAAARdata { pub rdata: Ipv6Addr diff --git a/dnstp/src/message/answer/mod.rs b/dnstp/src/message/record/mod.rs similarity index 100% rename from dnstp/src/message/answer/mod.rs rename to dnstp/src/message/record/mod.rs diff --git a/dnstp/src/message/answer/raw_rdata.rs b/dnstp/src/message/record/raw_rdata.rs similarity index 93% rename from dnstp/src/message/answer/raw_rdata.rs rename to dnstp/src/message/record/raw_rdata.rs index 278540b..d5210d0 100644 --- a/dnstp/src/message/answer/raw_rdata.rs +++ b/dnstp/src/message/record/raw_rdata.rs @@ -1,5 +1,5 @@ use std::fmt::{Debug, Formatter}; -use crate::message::answer::RData; +use crate::message::record::RData; pub struct RawRData { pub rdata: Vec diff --git a/dnstp/src/message/answer/tests.rs b/dnstp/src/message/record/tests.rs similarity index 96% rename from dnstp/src/message/answer/tests.rs rename to dnstp/src/message/record/tests.rs index 978ef48..70c1ad4 100644 --- a/dnstp/src/message/answer/tests.rs +++ b/dnstp/src/message/record/tests.rs @@ -1,4 +1,4 @@ -use crate::message::question::{DNSQuestion, QClass, QType, questions_from_bytes}; +use crate::message::question::{QClass, QType}; use super::*; diff --git a/dnstp/src/message/answer/txt_rdata.rs b/dnstp/src/message/record/txt_rdata.rs similarity index 93% rename from dnstp/src/message/answer/txt_rdata.rs rename to dnstp/src/message/record/txt_rdata.rs index f28c486..0ae1f43 100644 --- a/dnstp/src/message/answer/txt_rdata.rs +++ b/dnstp/src/message/record/txt_rdata.rs @@ -1,5 +1,5 @@ use std::fmt::{Debug, Formatter}; -use crate::message::answer::RData; +use crate::message::record::RData; pub struct TXTRdata { pub rdata: String diff --git a/dnstp/src/message_parser.rs b/dnstp/src/message_parser.rs index 956210f..9ba7e8c 100644 --- a/dnstp/src/message_parser.rs +++ b/dnstp/src/message_parser.rs @@ -1,5 +1,5 @@ use crate::byte; -use crate::message::{DNSMessage, Direction, DNSHeader, Opcode, ResponseCode, QuestionParseError, questions_from_bytes, records_from_bytes, RecordParseError, ResourceRecord}; +use crate::message::{DNSMessage, Direction, DNSHeader, Opcode, ResponseCode, QuestionParseError, questions_from_bytes, records_from_bytes, RecordParseError}; use crate::net::NetworkMessage; use crate::message_parser::RequestParseError::{HeaderParse, QuesionsParse}; @@ -96,7 +96,9 @@ pub fn parse_message(msg: NetworkMessage) -> Result { if remaining.len() > 0 { - let total_records = header.answer_record_count + header.authority_record_count + header.additional_record_count; + // can't handle EDNS records at the moment + // let total_records = header.answer_record_count + header.authority_record_count + header.additional_record_count; + let total_records = header.answer_record_count + header.authority_record_count; match records_from_bytes(remaining, total_records){ Ok((mut answers, _)) => { diff --git a/dnstp/src/processor/response.rs b/dnstp/src/processor/response.rs index 56c29c6..bce8b9b 100644 --- a/dnstp/src/processor/response.rs +++ b/dnstp/src/processor/response.rs @@ -1,11 +1,8 @@ -use std::net::Ipv4Addr; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; use std::thread; use log::{error, info}; -use std::str; use crate::message::{QuestionParseError, RecordParseError}; -use crate::net::NetworkMessage; use crate::net::raw_request::NetworkMessagePtr; use crate::message_parser::{HeaderParseError, parse_message, RequestParseError};