Loading doh/connection/driver.rs +1 −1 Original line number Diff line number Diff line Loading @@ -445,7 +445,7 @@ impl H3Driver { self.respond(stream_id) } h3::Event::Reset(e) => { debug!( warn!( "process_h3_event: h3::Event::Reset with error code {} on stream ID {}, network {}", e, stream_id, self.driver.net_id ); Loading doh/tests/doh_frontend/include/lib.rs.h +5 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,11 @@ bool frontend_set_max_streams_bidi(DohFrontend* doh, uint64_t value); /// Sets the `DohFrontend` to block or unblock sending any data. bool frontend_block_sending(DohFrontend* doh, bool block); /// If this function is called, the `DohFrontend` will send RESET_STREAM frame as a response /// instead of a DoH answer on the stream |stream_id|. This will make the client fail to receive /// this DoH answer. bool frontend_set_reset_stream_id(DohFrontend* doh, uint64_t stream_id); /// Gets the statistics of the `DohFrontend` and writes the result to |out|. bool frontend_stats(DohFrontend* doh, Stats* out); Loading doh/tests/doh_frontend/src/client.rs +13 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,11 @@ impl Client { } // Converts the clear-text DNS response to a DoH response, and sends it to the quiche. pub fn handle_backend_message(&mut self, response: &[u8]) -> Result<()> { pub fn handle_backend_message( &mut self, response: &[u8], send_reset_stream: Option<u64>, ) -> Result<()> { ensure!(self.h3_conn.is_some(), "HTTP/3 connection not created"); ensure!(response.len() >= DNS_HEADER_SIZE, "Insufficient bytes of DNS response"); Loading @@ -146,6 +150,14 @@ impl Client { .remove(&[response[0], response[1]]) .ok_or_else(|| anyhow!("query_id {:x} not found", query_id))?; if let Some(send_reset_stream) = send_reset_stream { if send_reset_stream == stream_id { self.conn.stream_shutdown(stream_id, quiche::Shutdown::Write, 99)?; info!("Preparing RESET_FRAME on stream {}", stream_id); return Ok(()); } } info!("Preparing HTTP/3 response {:?} on stream {}", headers, stream_id); h3_conn.send_response(&mut self.conn, stream_id, &headers, false)?; Loading doh/tests/doh_frontend/src/config.rs +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ pub struct Config { pub max_idle_timeout: u64, pub max_buffer_size: u64, pub max_streams_bidi: u64, pub reset_stream_id: Option<u64>, } impl Config { Loading doh/tests/doh_frontend/src/dns_https_frontend.rs +7 −1 Original line number Diff line number Diff line Loading @@ -187,6 +187,11 @@ impl DohFrontend { Ok(()) } pub fn set_reset_stream_id(&self, value: u64) -> Result<()> { self.config.lock().unwrap().reset_stream_id = Some(value); Ok(()) } pub fn request_stats(&mut self) -> Result<Stats> { ensure!( self.command_tx.is_some(), Loading Loading @@ -360,7 +365,8 @@ async fn worker_thread(params: WorkerParams) -> Result<()> { let query_id = [backend_buf[0], backend_buf[1]]; for (_, client) in clients.iter_mut() { if client.is_waiting_for_query(&query_id) { if let Err(e) = client.handle_backend_message(&backend_buf[..len]) { let reset_stream_id = config.lock().unwrap().reset_stream_id; if let Err(e) = client.handle_backend_message(&backend_buf[..len], reset_stream_id) { error!("Failed to handle message from backend: {}", e); } let connection_id = client.connection_id().clone(); Loading Loading
doh/connection/driver.rs +1 −1 Original line number Diff line number Diff line Loading @@ -445,7 +445,7 @@ impl H3Driver { self.respond(stream_id) } h3::Event::Reset(e) => { debug!( warn!( "process_h3_event: h3::Event::Reset with error code {} on stream ID {}, network {}", e, stream_id, self.driver.net_id ); Loading
doh/tests/doh_frontend/include/lib.rs.h +5 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,11 @@ bool frontend_set_max_streams_bidi(DohFrontend* doh, uint64_t value); /// Sets the `DohFrontend` to block or unblock sending any data. bool frontend_block_sending(DohFrontend* doh, bool block); /// If this function is called, the `DohFrontend` will send RESET_STREAM frame as a response /// instead of a DoH answer on the stream |stream_id|. This will make the client fail to receive /// this DoH answer. bool frontend_set_reset_stream_id(DohFrontend* doh, uint64_t stream_id); /// Gets the statistics of the `DohFrontend` and writes the result to |out|. bool frontend_stats(DohFrontend* doh, Stats* out); Loading
doh/tests/doh_frontend/src/client.rs +13 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,11 @@ impl Client { } // Converts the clear-text DNS response to a DoH response, and sends it to the quiche. pub fn handle_backend_message(&mut self, response: &[u8]) -> Result<()> { pub fn handle_backend_message( &mut self, response: &[u8], send_reset_stream: Option<u64>, ) -> Result<()> { ensure!(self.h3_conn.is_some(), "HTTP/3 connection not created"); ensure!(response.len() >= DNS_HEADER_SIZE, "Insufficient bytes of DNS response"); Loading @@ -146,6 +150,14 @@ impl Client { .remove(&[response[0], response[1]]) .ok_or_else(|| anyhow!("query_id {:x} not found", query_id))?; if let Some(send_reset_stream) = send_reset_stream { if send_reset_stream == stream_id { self.conn.stream_shutdown(stream_id, quiche::Shutdown::Write, 99)?; info!("Preparing RESET_FRAME on stream {}", stream_id); return Ok(()); } } info!("Preparing HTTP/3 response {:?} on stream {}", headers, stream_id); h3_conn.send_response(&mut self.conn, stream_id, &headers, false)?; Loading
doh/tests/doh_frontend/src/config.rs +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ pub struct Config { pub max_idle_timeout: u64, pub max_buffer_size: u64, pub max_streams_bidi: u64, pub reset_stream_id: Option<u64>, } impl Config { Loading
doh/tests/doh_frontend/src/dns_https_frontend.rs +7 −1 Original line number Diff line number Diff line Loading @@ -187,6 +187,11 @@ impl DohFrontend { Ok(()) } pub fn set_reset_stream_id(&self, value: u64) -> Result<()> { self.config.lock().unwrap().reset_stream_id = Some(value); Ok(()) } pub fn request_stats(&mut self) -> Result<Stats> { ensure!( self.command_tx.is_some(), Loading Loading @@ -360,7 +365,8 @@ async fn worker_thread(params: WorkerParams) -> Result<()> { let query_id = [backend_buf[0], backend_buf[1]]; for (_, client) in clients.iter_mut() { if client.is_waiting_for_query(&query_id) { if let Err(e) = client.handle_backend_message(&backend_buf[..len]) { let reset_stream_id = config.lock().unwrap().reset_stream_id; if let Err(e) = client.handle_backend_message(&backend_buf[..len], reset_stream_id) { error!("Failed to handle message from backend: {}", e); } let connection_id = client.connection_id().clone(); Loading