Loading doh/connection/driver.rs +1 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,7 @@ impl H3Driver { // If the request has already timed out, don't issue it to the server. if let Some(expiry) = request.expiry { if BootTime::now() > expiry { warn!("Abandoning expired DNS request"); return Ok(()); } } Loading doh/network/driver.rs +9 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ use crate::config::Config; use crate::connection::Connection; use crate::dispatcher::{QueryError, Response}; use crate::encoding; use anyhow::{anyhow, Result}; use anyhow::{anyhow, bail, Result}; use std::sync::Arc; use tokio::sync::{mpsc, watch}; use tokio::task; Loading Loading @@ -90,7 +90,7 @@ async fn build_connection( } impl Driver { const MAX_BUFFERED_COMMANDS: usize = 10; const MAX_BUFFERED_COMMANDS: usize = 50; pub async fn new( info: ServerInfo, Loading Loading @@ -175,6 +175,13 @@ impl Driver { } async fn send_query(&mut self, query: Query) -> Result<()> { // If the associated receiver has been closed, meaning that the request has already // timed out, just drop it. This check helps drain the channel quickly in the case // where the network is stalled. if query.response.is_closed() { bail!("Abandoning expired DNS request") } if !self.connection.wait_for_live().await { // Try reconnecting self.connection = Loading doh/network/mod.rs +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ impl Network { .unwrap_or_else(|_| { warn!("Query result listener went away before receiving a response") }), Status::Live => self.command_tx.send(Command::Query(query)).await?, Status::Live => self.command_tx.try_send(Command::Query(query))?, } Ok(()) } Loading tests/doh/include/lib.rs.h +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ struct Stats { uint32_t queries_received; /// The number of accumulated QUIC connections accepted. uint32_t connections_accepted; /// The number of QUIC connections alive. uint32_t alive_connections; }; extern "C" { Loading tests/doh/src/client.rs +8 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,10 @@ impl Client { pub fn on_timeout(&mut self) { self.conn.on_timeout(); } pub fn is_alive(&self) -> bool { self.conn.is_established() && !self.conn.is_closed() } } impl std::fmt::Debug for Client { Loading Loading @@ -286,6 +290,10 @@ impl ClientMap { self.clients.iter_mut() } pub fn iter(&mut self) -> hash_map::Iter<ConnectionID, Client> { self.clients.iter() } pub fn len(&mut self) -> usize { self.clients.len() } Loading Loading
doh/connection/driver.rs +1 −0 Original line number Diff line number Diff line Loading @@ -283,6 +283,7 @@ impl H3Driver { // If the request has already timed out, don't issue it to the server. if let Some(expiry) = request.expiry { if BootTime::now() > expiry { warn!("Abandoning expired DNS request"); return Ok(()); } } Loading
doh/network/driver.rs +9 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ use crate::config::Config; use crate::connection::Connection; use crate::dispatcher::{QueryError, Response}; use crate::encoding; use anyhow::{anyhow, Result}; use anyhow::{anyhow, bail, Result}; use std::sync::Arc; use tokio::sync::{mpsc, watch}; use tokio::task; Loading Loading @@ -90,7 +90,7 @@ async fn build_connection( } impl Driver { const MAX_BUFFERED_COMMANDS: usize = 10; const MAX_BUFFERED_COMMANDS: usize = 50; pub async fn new( info: ServerInfo, Loading Loading @@ -175,6 +175,13 @@ impl Driver { } async fn send_query(&mut self, query: Query) -> Result<()> { // If the associated receiver has been closed, meaning that the request has already // timed out, just drop it. This check helps drain the channel quickly in the case // where the network is stalled. if query.response.is_closed() { bail!("Abandoning expired DNS request") } if !self.connection.wait_for_live().await { // Try reconnecting self.connection = Loading
doh/network/mod.rs +1 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ impl Network { .unwrap_or_else(|_| { warn!("Query result listener went away before receiving a response") }), Status::Live => self.command_tx.send(Command::Query(query)).await?, Status::Live => self.command_tx.try_send(Command::Query(query))?, } Ok(()) } Loading
tests/doh/include/lib.rs.h +2 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ struct Stats { uint32_t queries_received; /// The number of accumulated QUIC connections accepted. uint32_t connections_accepted; /// The number of QUIC connections alive. uint32_t alive_connections; }; extern "C" { Loading
tests/doh/src/client.rs +8 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,10 @@ impl Client { pub fn on_timeout(&mut self) { self.conn.on_timeout(); } pub fn is_alive(&self) -> bool { self.conn.is_established() && !self.conn.is_closed() } } impl std::fmt::Debug for Client { Loading Loading @@ -286,6 +290,10 @@ impl ClientMap { self.clients.iter_mut() } pub fn iter(&mut self) -> hash_map::Iter<ConnectionID, Client> { self.clients.iter() } pub fn len(&mut self) -> usize { self.clients.len() } Loading