Revert "Use configured values for local and remote address, not globals"

I don't understand that change.
This commit is contained in:
Frank Denis 2018-05-19 01:57:55 +02:00
parent 66f68b8fac
commit 20b7dd9491

View file

@ -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<u8>,
local_addr: SocketAddr,
remote_addr: SocketAddr,
) -> Box<Future<Item = Response, Error = ()>> {
fn proxy(query: Vec<u8>) -> Box<Future<Item = Response, Error = ()>> {
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<Future<Item = Response, Error = ()>> {
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<Future<Item = _, Error = _>>;
}
Box::new(Self::proxy(query, local_addr, server_addr))
Box::new(Self::proxy(query))
});
Box::new(fut)
}