This commit is contained in:
Frank Denis 2021-01-01 00:03:32 +01:00
parent 3ee8477ffa
commit b544ca3daa
5 changed files with 12 additions and 20 deletions

View file

@ -19,7 +19,7 @@ tls = ["libdoh/tls"]
libdoh = { path = "src/libdoh", version = "0.3.3" }
clap = "2.33.3"
jemallocator = "0.3.2"
tokio = { version = "0.2.24", features = ["rt-threaded", "time", "tcp", "udp", "stream", "parking_lot"] }
tokio = { version = "1.0.0", features = ["net", "io-std", "io-util", "fs", "time", "rt-multi-thread", "parking_lot"] }
[package.metadata.deb]
extended-description = """\

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018-2020 Frank Denis
Copyright (c) 2018-2021 Frank Denis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -11,17 +11,17 @@ categories = ["asynchronous", "network-programming","command-line-utilities"]
edition = "2018"
[features]
default = []
default = ["tls"]
tls = ["tokio-rustls"]
[dependencies]
anyhow = "1.0.35"
anyhow = "1.0.36"
byteorder = "1.3.4"
base64 = "0.13.0"
futures = "0.3.8"
hyper = { version = "0.13.9", default-features = false, features = ["stream"] }
tokio = { version = "0.2.24", features = ["rt-threaded", "time", "tcp", "udp", "stream", "parking_lot"] }
tokio-rustls = { version = "0.15.0", optional = true }
hyper = { version = "0.14.1", default-features = false, features = ["server", "http1", "http2", "stream"] }
tokio = { version = "1.0.0", features = ["full"] }
tokio-rustls = { version = "0.21.1", optional = true }
[profile.release]
codegen-units = 1

View file

@ -179,7 +179,7 @@ impl DoH {
}
let _ = dns::set_edns_max_payload_size(&mut query, MAX_DNS_RESPONSE_LEN as _);
let globals = &self.globals;
let mut socket = UdpSocket::bind(&globals.local_bind_address)
let socket = UdpSocket::bind(&globals.local_bind_address)
.await
.map_err(DoHError::Io)?;
let expected_server_address = globals.server_address;
@ -245,15 +245,11 @@ impl DoH {
async fn start_without_tls(
self,
mut listener: TcpListener,
listener: TcpListener,
server: Http<LocalExecutor>,
) -> Result<(), DoHError> {
let listener_service = async {
while let Some(stream) = listener.incoming().next().await {
let stream = match stream {
Ok(stream) => stream,
Err(_) => continue,
};
while let Ok((stream, _client_addr)) = listener.accept().await {
self.clone().client_serve(stream, server.clone()).await;
}
Ok(()) as Result<(), DoHError>

View file

@ -7,11 +7,11 @@ use std::io::{self, BufReader};
use std::path::Path;
use std::sync::Arc;
use tokio::net::TcpListener;
use tokio::stream::StreamExt;
use tokio_rustls::{
rustls::{internal::pemfile, NoClientAuth, ServerConfig},
TlsAcceptor,
};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
pub fn create_tls_acceptor<P, P2>(certs_path: P, certs_keys_path: P2) -> io::Result<TlsAcceptor>
where
@ -86,11 +86,7 @@ impl DoH {
server: Http<LocalExecutor>,
) -> Result<(), DoHError> {
let listener_service = async {
while let Some(raw_stream) = listener.incoming().next().await {
let raw_stream = match raw_stream {
Ok(raw_stream) => raw_stream,
Err(_) => continue,
};
while let Ok((raw_stream, _client_addr)) = listener.accept().await {
let stream = match tls_acceptor.accept(raw_stream).await {
Ok(stream) => stream,
Err(_) => continue,