adding txt rdata

This commit is contained in:
Andy Pack 2024-02-07 21:51:31 +00:00
parent bda56b4084
commit fdc8a7e338
Signed by: sarsoo
GPG Key ID: A55BA3536A5E0ED7
6 changed files with 36 additions and 4 deletions

View File

@ -16,7 +16,7 @@ impl Debug for ARdata {
impl RData for ARdata { impl RData for ARdata {
fn to_bytes(&self) -> Vec<u8> { fn to_bytes(&self) -> Vec<u8> {
return self.rdata.octets().to_vec(); self.rdata.octets().to_vec()
} }
} }

View File

@ -16,7 +16,7 @@ impl Debug for AAAARdata {
impl RData for AAAARdata { impl RData for AAAARdata {
fn to_bytes(&self) -> Vec<u8> { fn to_bytes(&self) -> Vec<u8> {
return self.rdata.octets().to_vec(); self.rdata.octets().to_vec()
} }
} }

View File

@ -7,6 +7,9 @@ pub use a_rdata::ARdata;
mod aaaa_rdata; mod aaaa_rdata;
pub use aaaa_rdata::AAAARdata; pub use aaaa_rdata::AAAARdata;
mod txt_rdata;
pub use txt_rdata::TXTRdata;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View File

@ -15,7 +15,7 @@ impl Debug for RawRData {
impl RData for RawRData { impl RData for RawRData {
fn to_bytes(&self) -> Vec<u8> { fn to_bytes(&self) -> Vec<u8> {
return self.rdata.clone(); self.rdata.clone()
} }
} }

View File

@ -0,0 +1,29 @@
use std::fmt::{Debug, Formatter};
use crate::message::answer::RData;
pub struct TXTRdata {
pub rdata: String
}
impl Debug for TXTRdata {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.debug_struct("TXT")
.field("data", &self.rdata)
.finish()
}
}
impl RData for TXTRdata {
fn to_bytes(&self) -> Vec<u8> {
self.rdata.into_bytes()
}
}
impl TXTRdata {
pub fn from(rdata: String) -> TXTRdata
{
TXTRdata {
rdata
}
}
}

View File

@ -6,7 +6,7 @@ pub mod answer;
pub mod response; pub mod response;
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, RecordParseError, records_to_bytes, answers_from_bytes}; pub use answer::{ResourceRecord, RawRData, RData, ARdata, AAAARdata, TXTRdata, RecordParseError, records_to_bytes, answers_from_bytes};
pub use header::{DNSHeader, Direction, Opcode, ResponseCode, HEADER_SIZE}; pub use header::{DNSHeader, Direction, Opcode, ResponseCode, HEADER_SIZE};
pub use request::DNSRequest; pub use request::DNSRequest;
pub use response::DNSResponse; pub use response::DNSResponse;