moving message module to record, skipping additional records while thinking about EDNS
This commit is contained in:
parent
c64691de92
commit
ee9022211e
@ -1,5 +1,5 @@
|
|||||||
use std::net::{Ipv4Addr, SocketAddr};
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct DNSMessage {
|
pub struct DNSMessage {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
pub mod header;
|
pub mod header;
|
||||||
pub mod question;
|
pub mod question;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
pub mod answer;
|
pub mod record;
|
||||||
|
|
||||||
pub use question::{DNSQuestion, QClass, QType, QuestionParseError, questions_to_bytes, questions_from_bytes};
|
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 header::{DNSHeader, Direction, Opcode, ResponseCode, HEADER_SIZE};
|
||||||
pub use message::DNSMessage;
|
pub use message::DNSMessage;
|
@ -2,7 +2,7 @@
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use urlencoding::decode;
|
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;
|
use crate::string::encode_domain_name;
|
||||||
|
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
@ -21,6 +21,7 @@ pub enum QType {
|
|||||||
RP = 17,
|
RP = 17,
|
||||||
AAAA = 28,
|
AAAA = 28,
|
||||||
SRV = 33,
|
SRV = 33,
|
||||||
|
OPT = 41,
|
||||||
ANY = 255,
|
ANY = 255,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
use crate::message::answer::RData;
|
use crate::message::record::RData;
|
||||||
|
|
||||||
pub struct ARdata {
|
pub struct ARdata {
|
||||||
pub rdata: Ipv4Addr
|
pub rdata: Ipv4Addr
|
@ -1,6 +1,6 @@
|
|||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
use std::net::Ipv6Addr;
|
||||||
use crate::message::answer::RData;
|
use crate::message::record::RData;
|
||||||
|
|
||||||
pub struct AAAARdata {
|
pub struct AAAARdata {
|
||||||
pub rdata: Ipv6Addr
|
pub rdata: Ipv6Addr
|
@ -1,5 +1,5 @@
|
|||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use crate::message::answer::RData;
|
use crate::message::record::RData;
|
||||||
|
|
||||||
pub struct RawRData {
|
pub struct RawRData {
|
||||||
pub rdata: Vec<u8>
|
pub rdata: Vec<u8>
|
@ -1,4 +1,4 @@
|
|||||||
use crate::message::question::{DNSQuestion, QClass, QType, questions_from_bytes};
|
use crate::message::question::{QClass, QType};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use crate::message::answer::RData;
|
use crate::message::record::RData;
|
||||||
|
|
||||||
pub struct TXTRdata {
|
pub struct TXTRdata {
|
||||||
pub rdata: String
|
pub rdata: String
|
@ -1,5 +1,5 @@
|
|||||||
use crate::byte;
|
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::net::NetworkMessage;
|
||||||
use crate::message_parser::RequestParseError::{HeaderParse, QuesionsParse};
|
use crate::message_parser::RequestParseError::{HeaderParse, QuesionsParse};
|
||||||
|
|
||||||
@ -96,7 +96,9 @@ pub fn parse_message(msg: NetworkMessage) -> Result<DNSMessage, RequestParseErro
|
|||||||
Ok((questions, remaining)) => {
|
Ok((questions, remaining)) => {
|
||||||
if remaining.len() > 0 {
|
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){
|
match records_from_bytes(remaining, total_records){
|
||||||
Ok((mut answers, _)) => {
|
Ok((mut answers, _)) => {
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
use std::net::Ipv4Addr;
|
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use std::str;
|
|
||||||
use crate::message::{QuestionParseError, RecordParseError};
|
use crate::message::{QuestionParseError, RecordParseError};
|
||||||
use crate::net::NetworkMessage;
|
|
||||||
use crate::net::raw_request::NetworkMessagePtr;
|
use crate::net::raw_request::NetworkMessagePtr;
|
||||||
use crate::message_parser::{HeaderParseError, parse_message, RequestParseError};
|
use crate::message_parser::{HeaderParseError, parse_message, RequestParseError};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user