client & server: revert changes to parse the response

* There is no need to do so.
* Our issue was caused by missing Content-Length
This commit is contained in:
Peter Cai 2021-04-06 08:28:11 +08:00
parent d28596f744
commit 7bc00c3da7
3 changed files with 4 additions and 33 deletions

View File

@ -173,15 +173,6 @@ impl Client {
record.data().data().to_vec(),
),
);
// Try to parse the record; if failed, fail this entire query
let parsed_record_data = crate::util::parse_record_data(record.data());
if let Err(_) = parsed_record_data {
return Err("Failed to parse response from upstream".to_string());
} else if let Ok(None) = parsed_record_data {
return Err("Upstream did not respond our query".to_string());
}
ret.push(owned_record);
}
Ok(ret)

View File

@ -226,13 +226,9 @@ impl Server {
// Set up the answer section
let mut answer_builder = question_builder.answer();
for r in records {
if let Ok(Some(data)) = crate::util::parse_record_data(r.data()) {
answer_builder
.push(Record::new(r.owner().clone(), r.class(), r.ttl(), data))
.map_err(|_| "Max answer size exceeded".to_string())?;
} else {
return Err("Cannot parse record data responded by resolver client".to_string());
}
answer_builder
.push(r)
.map_err(|_| "Max answer size exceeded".to_string())?;
}
Ok(answer_builder.into_message())
}

View File

@ -1,11 +1,4 @@
use domain::{
base::{
octets::{ParseError, Parser},
rdata::{ParseRecordData, UnknownRecordData},
Message, ParsedDname,
},
rdata::AllRecordData,
};
use domain::base::Message;
use js_sys::{Math, Promise};
use std::ops::Add;
use std::{collections::hash_map::DefaultHasher, hash::Hasher};
@ -28,15 +21,6 @@ pub fn parse_dns_wireformat(msg: &[u8]) -> Result<Message<Vec<u8>>, String> {
.map_err(|_| "Failed to parse DNS wireformat message".to_string())
}
pub fn parse_record_data<T: AsRef<[u8]>>(
record: &UnknownRecordData<T>,
) -> Result<Option<AllRecordData<&[u8], ParsedDname<&[u8]>>>, ParseError> {
AllRecordData::parse_data(
record.rtype(),
&mut Parser::from_ref(record.data().as_ref()),
)
}
// Rust wrapper around JS functions
// For convenience, and also to work around bugs in rust-analyzer
// which thinks all JS functions are "unsafe"