Loading tests/doh/src/client.rs +11 −11 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ //! Client management, including the communication with quiche I/O. use anyhow::{anyhow, bail, ensure, Result}; use log::{debug, info, warn}; use log::{debug, error, info, warn}; use quiche::h3::NameValue; use ring::hmac; use ring::rand::SystemRandom; Loading Loading @@ -170,16 +170,16 @@ impl Client { pub fn flush_egress(&mut self) -> Result<Vec<u8>> { let mut ret = vec![]; let mut buf = [0; MAX_UDP_PAYLOAD_SIZE]; loop { let (write, _) = match self.conn.send(&mut buf) { Ok(v) => v, Err(quiche::Error::Done) => break, // Maybe close the connection? Err(e) => bail!(e), Err(quiche::Error::Done) => bail!(quiche::Error::Done), Err(e) => { error!("flush_egress failed: {}", e); bail!(e) } }; ret.append(&mut buf[..write].to_vec()); } Ok(ret) } Loading tests/doh/src/dns_https_frontend.rs +5 −13 Original line number Diff line number Diff line Loading @@ -304,21 +304,13 @@ async fn worker_thread(params: WorkerParams) -> Result<()> { match command { Command::MaybeWrite {connection_id} => { if let Some(client) = clients.get_mut(&connection_id) { match client.flush_egress() { Ok(v) => { // The DoH engine in DnsResolver can't handle empty response. if !v.is_empty() { while let Ok(v) = client.flush_egress() { let addr = client.addr(); debug!("Sending {} bytes to client {}", v.len(), addr); if let Err(e) = frontend_socket.send_to(&v, addr).await { error!("Failed to send packet to {:?}: {:?}", client, e); } } } Err(e) => { error!("flush_egress failed: {}", e); } } client.process_pending_answers()?; } } Loading Loading
tests/doh/src/client.rs +11 −11 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ //! Client management, including the communication with quiche I/O. use anyhow::{anyhow, bail, ensure, Result}; use log::{debug, info, warn}; use log::{debug, error, info, warn}; use quiche::h3::NameValue; use ring::hmac; use ring::rand::SystemRandom; Loading Loading @@ -170,16 +170,16 @@ impl Client { pub fn flush_egress(&mut self) -> Result<Vec<u8>> { let mut ret = vec![]; let mut buf = [0; MAX_UDP_PAYLOAD_SIZE]; loop { let (write, _) = match self.conn.send(&mut buf) { Ok(v) => v, Err(quiche::Error::Done) => break, // Maybe close the connection? Err(e) => bail!(e), Err(quiche::Error::Done) => bail!(quiche::Error::Done), Err(e) => { error!("flush_egress failed: {}", e); bail!(e) } }; ret.append(&mut buf[..write].to_vec()); } Ok(ret) } Loading
tests/doh/src/dns_https_frontend.rs +5 −13 Original line number Diff line number Diff line Loading @@ -304,21 +304,13 @@ async fn worker_thread(params: WorkerParams) -> Result<()> { match command { Command::MaybeWrite {connection_id} => { if let Some(client) = clients.get_mut(&connection_id) { match client.flush_egress() { Ok(v) => { // The DoH engine in DnsResolver can't handle empty response. if !v.is_empty() { while let Ok(v) = client.flush_egress() { let addr = client.addr(); debug!("Sending {} bytes to client {}", v.len(), addr); if let Err(e) = frontend_socket.send_to(&v, addr).await { error!("Failed to send packet to {:?}: {:?}", client, e); } } } Err(e) => { error!("flush_egress failed: {}", e); } } client.process_pending_answers()?; } } Loading