diff --git a/Cargo.toml b/Cargo.toml index e09c742..6e06d15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = """\ diff --git a/LICENSE b/LICENSE index 23ba07f..010ad6e 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/src/libdoh/Cargo.toml b/src/libdoh/Cargo.toml index 5a3dcc8..62e69d1 100644 --- a/src/libdoh/Cargo.toml +++ b/src/libdoh/Cargo.toml @@ -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 diff --git a/src/libdoh/src/lib.rs b/src/libdoh/src/lib.rs index 44477d4..567b299 100644 --- a/src/libdoh/src/lib.rs +++ b/src/libdoh/src/lib.rs @@ -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, ) -> 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> diff --git a/src/libdoh/src/tls.rs b/src/libdoh/src/tls.rs index 2aee569..85beebf 100644 --- a/src/libdoh/src/tls.rs +++ b/src/libdoh/src/tls.rs @@ -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(certs_path: P, certs_keys_path: P2) -> io::Result where @@ -86,11 +86,7 @@ impl DoH { server: Http, ) -> 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,