mirror of
https://github.com/DNSCrypt/doh-server.git
synced 2025-04-05 05:57:38 +03:00
Revert "Use configured values for local and remote address, not globals"
I don't understand that change.
This commit is contained in:
parent
66f68b8fac
commit
20b7dd9491
1 changed files with 5 additions and 9 deletions
14
src/main.rs
14
src/main.rs
|
@ -118,7 +118,7 @@ impl DoH {
|
||||||
return Box::new(future::ok(response));
|
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));
|
return Box::new(fut.map_err(|_| hyper::Error::Incomplete));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
@ -128,12 +128,10 @@ impl DoH {
|
||||||
Box::new(future::ok(response))
|
Box::new(future::ok(response))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn proxy(
|
fn proxy(query: Vec<u8>) -> Box<Future<Item = Response, Error = ()>> {
|
||||||
query: Vec<u8>,
|
let local_addr = LOCAL_BIND_ADDRESS.parse().unwrap();
|
||||||
local_addr: SocketAddr,
|
|
||||||
remote_addr: SocketAddr,
|
|
||||||
) -> Box<Future<Item = Response, Error = ()>> {
|
|
||||||
let socket = UdpSocket::bind(&local_addr).unwrap();
|
let socket = UdpSocket::bind(&local_addr).unwrap();
|
||||||
|
let remote_addr: SocketAddr = SERVER_ADDRESS.parse().unwrap();
|
||||||
let fut = socket
|
let fut = socket
|
||||||
.send_dgram(query, &remote_addr)
|
.send_dgram(query, &remote_addr)
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
|
@ -166,8 +164,6 @@ impl DoH {
|
||||||
|
|
||||||
fn read_body_and_proxy(&self, body: Body) -> Box<Future<Item = Response, Error = ()>> {
|
fn read_body_and_proxy(&self, body: Body) -> Box<Future<Item = Response, Error = ()>> {
|
||||||
let mut sum_size = 0;
|
let mut sum_size = 0;
|
||||||
let local_addr = self.local_bind_address.clone();
|
|
||||||
let server_addr = self.server_address.clone();
|
|
||||||
let fut =
|
let fut =
|
||||||
body.and_then(move |chunk| {
|
body.and_then(move |chunk| {
|
||||||
sum_size += chunk.len();
|
sum_size += chunk.len();
|
||||||
|
@ -183,7 +179,7 @@ impl DoH {
|
||||||
if query.len() < MIN_DNS_PACKET_LEN {
|
if query.len() < MIN_DNS_PACKET_LEN {
|
||||||
return Box::new(future::err(())) as Box<Future<Item = _, Error = _>>;
|
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)
|
Box::new(fut)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue