moving message module to record, skipping additional records while thinking about EDNS

This commit is contained in:
Andy Pack 2024-02-08 23:04:16 +00:00
parent c64691de92
commit ee9022211e
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
11 changed files with 15 additions and 15 deletions

View File

@ -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 {

View File

@ -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;

View File

@ -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,
}

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -1,4 +1,4 @@
use crate::message::question::{DNSQuestion, QClass, QType, questions_from_bytes};
use crate::message::question::{QClass, QType};
use super::*;

View File

@ -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

View File

@ -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<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, _)) => {

View File

@ -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};