pull/79/head
Frank Denis 2 years ago
parent 714241e2d5
commit 025c3b99c3

@ -15,7 +15,7 @@ use tokio::net::{TcpSocket, UdpSocket};
pub async fn resolve_udp( pub async fn resolve_udp(
globals: &Globals, globals: &Globals,
mut packet: &mut Vec<u8>, packet: &mut Vec<u8>,
packet_qname: &[u8], packet_qname: &[u8],
tid: u16, tid: u16,
has_cached_response: bool, has_cached_response: bool,
@ -39,7 +39,7 @@ pub async fn resolve_udp(
}, },
}; };
ext_socket.connect(globals.upstream_addr).await?; ext_socket.connect(globals.upstream_addr).await?;
dns::set_edns_max_payload_size(&mut packet, DNS_MAX_PACKET_SIZE as u16)?; dns::set_edns_max_payload_size(packet, DNS_MAX_PACKET_SIZE as u16)?;
let mut response; let mut response;
let timeout = if has_cached_response { let timeout = if has_cached_response {
globals.udp_timeout / 2 globals.udp_timeout / 2
@ -123,7 +123,7 @@ pub async fn resolve_tcp(
pub async fn resolve( pub async fn resolve(
globals: &Globals, globals: &Globals,
mut packet: &mut Vec<u8>, packet: &mut Vec<u8>,
packet_qname: Vec<u8>, packet_qname: Vec<u8>,
cached_response: Option<CachedResponse>, cached_response: Option<CachedResponse>,
packet_hash: u128, packet_hash: u128,
@ -132,7 +132,7 @@ pub async fn resolve(
#[cfg(feature = "metrics")] #[cfg(feature = "metrics")]
globals.varz.upstream_sent.inc(); globals.varz.upstream_sent.inc();
let tid = random(); let tid = random();
dns::set_tid(&mut packet, tid); dns::set_tid(packet, tid);
let mut response = resolve_udp( let mut response = resolve_udp(
globals, globals,
packet, packet,
@ -183,7 +183,7 @@ pub async fn resolve(
pub async fn get_cached_response_or_resolve( pub async fn get_cached_response_or_resolve(
globals: &Globals, globals: &Globals,
client_ctx: &ClientCtx, client_ctx: &ClientCtx,
mut packet: &mut Vec<u8>, packet: &mut Vec<u8>,
) -> Result<Vec<u8>, Error> { ) -> Result<Vec<u8>, Error> {
let packet_qname = dns::qname(packet)?; let packet_qname = dns::qname(packet)?;
if let Some(my_ip) = &globals.my_ip { if let Some(my_ip) = &globals.my_ip {
@ -221,8 +221,8 @@ pub async fn get_cached_response_or_resolve(
return dns::serve_nxdomain_response(packet.to_vec()); return dns::serve_nxdomain_response(packet.to_vec());
} }
let original_tid = dns::tid(packet); let original_tid = dns::tid(packet);
dns::set_tid(&mut packet, 0); dns::set_tid(packet, 0);
dns::normalize_qname(&mut packet)?; dns::normalize_qname(packet)?;
let mut hasher = globals.hasher; let mut hasher = globals.hasher;
hasher.write(packet); hasher.write(packet);
let packet_hash = hasher.finish128().as_u128(); let packet_hash = hasher.finish128().as_u128();

Loading…
Cancel
Save