diff --git a/src/main.rs b/src/main.rs index 3ac9356..4fe5224 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,7 +118,7 @@ impl DoH { return Box::new(future::ok(response)); } }; - let fut = Self::proxy(question, self.local_bind_address, self.server_address); + let fut = Self::proxy(question); return Box::new(fut.map_err(|_| hyper::Error::Incomplete)); } _ => { @@ -128,12 +128,10 @@ impl DoH { Box::new(future::ok(response)) } - fn proxy( - query: Vec, - local_addr: SocketAddr, - remote_addr: SocketAddr, - ) -> Box> { + fn proxy(query: Vec) -> Box> { + let local_addr = LOCAL_BIND_ADDRESS.parse().unwrap(); let socket = UdpSocket::bind(&local_addr).unwrap(); + let remote_addr: SocketAddr = SERVER_ADDRESS.parse().unwrap(); let fut = socket .send_dgram(query, &remote_addr) .map_err(|_| ()) @@ -166,8 +164,6 @@ impl DoH { fn read_body_and_proxy(&self, body: Body) -> Box> { let mut sum_size = 0; - let local_addr = self.local_bind_address.clone(); - let server_addr = self.server_address.clone(); let fut = body.and_then(move |chunk| { sum_size += chunk.len(); @@ -183,7 +179,7 @@ impl DoH { if query.len() < MIN_DNS_PACKET_LEN { return Box::new(future::err(())) as Box>; } - Box::new(Self::proxy(query, local_addr, server_addr)) + Box::new(Self::proxy(query)) }); Box::new(fut) }