Skip to content

Commit

Permalink
moving message module to record, skipping additional records while th…
Browse files Browse the repository at this point in the history
…inking about EDNS
  • Loading branch information
Sarsoo committed Feb 8, 2024
1 parent c64691d commit ee90222
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dnstp/src/message/message.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions dnstp/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion dnstp/src/message/question/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -21,6 +21,7 @@ pub enum QType {
RP = 17,
AAAA = 28,
SRV = 33,
OPT = 41,
ANY = 255,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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<u8>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::message::question::{DNSQuestion, QClass, QType, questions_from_bytes};
use crate::message::question::{QClass, QType};

use super::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions dnstp/src/message_parser.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -96,7 +96,9 @@ pub fn parse_message(msg: NetworkMessage) -> Result<DNSMessage, RequestParseErro
Ok((questions, remaining)) => {
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, _)) => {
Expand Down
3 changes: 0 additions & 3 deletions dnstp/src/processor/response.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down

0 comments on commit ee90222

Please sign in to comment.