Loading doh/connection/driver.rs +27 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ use std::collections::HashMap; use std::default::Default; use std::future; use std::io; use std::pin::Pin; use thiserror::Error; use tokio::net::UdpSocket; use tokio::select; Loading Loading @@ -80,7 +79,7 @@ const MAX_UDP_PACKET_SIZE: usize = 65536; struct Driver { request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, // This buffer is large, boxing it will keep it // off the stack and prevent it being copied during Loading Loading @@ -119,7 +118,7 @@ async fn optional_timeout(timeout: Option<boot_time::Duration>, net_id: u32) { pub async fn drive( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Result<()> { Loading @@ -130,7 +129,7 @@ impl Driver { fn new( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Self { Loading Loading @@ -163,7 +162,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); let session = self.quiche_conn.session().map(<[_]>::to_vec); let _ = self.status_tx.send(Status::Dead { session }); Err(Error::Closed) } else { Ok(()) Loading @@ -180,7 +180,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); let session = self.quiche_conn.session().map(<[_]>::to_vec); let _ = self.status_tx.send(Status::Dead { session }); self.request_rx.close(); // Drain the pending DNS requests from the queue to make their corresponding future Loading Loading @@ -265,10 +266,8 @@ impl H3Driver { let _ = self.driver.status_tx.send(Status::H3); loop { if let Err(e) = self.drive_once().await { let _ = self .driver .status_tx .send(Status::Dead { session: self.driver.quiche_conn.session() }); let session = self.driver.quiche_conn.session().map(<[_]>::to_vec); let _ = self.driver.status_tx.send(Status::Dead { session }); return Err(e); } } Loading Loading @@ -445,17 +444,30 @@ impl H3Driver { ); self.respond(stream_id) } // This clause is for quiche 0.10.x, we're still on 0.9.x //h3::Event::Reset(e) => { // self.streams.get_mut(&stream_id).map(|stream| stream.error = Some(e)); // self.respond(stream_id); //} h3::Event::Reset(e) => { debug!( "process_h3_event: h3::Event::Reset with error code {} on stream ID {}, network {}", e, stream_id, self.driver.net_id ); if let Some(stream) = self.streams.get_mut(&stream_id) { stream.error = Some(e) } self.respond(stream_id); } h3::Event::Datagram => { warn!("Unexpected Datagram received"); // We don't care if something went wrong with the datagram, we didn't // want it anyways. let _ = self.discard_datagram(stream_id); } h3::Event::PriorityUpdate => { debug!( "process_h3_event: h3::Event::PriorityUpdate on stream ID {}, network {}", stream_id, self.driver.net_id ); // It tells us that PRIORITY_UPDATE frame is received, but we are not // using it in our code currently. No-op should be fine. } h3::Event::GoAway => self.shutdown(false, b"SERVER GOAWAY").await?, } Ok(()) Loading doh/tests/doh_frontend/src/client.rs +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ use log::{debug, error, info, warn}; use quiche::h3::NameValue; use std::collections::{hash_map, HashMap}; use std::net::SocketAddr; use std::pin::Pin; use std::time::Duration; pub const DNS_HEADER_SIZE: usize = 12; Loading @@ -35,7 +34,7 @@ const URL_PATH_PREFIX: &str = "/dns-query?dns="; /// Manages a QUIC and HTTP/3 connection. No socket I/O operations. pub struct Client { /// QUIC connection. conn: Pin<Box<quiche::Connection>>, conn: quiche::Connection, /// HTTP/3 connection. h3_conn: Option<quiche::h3::Connection>, Loading @@ -59,7 +58,7 @@ pub struct Client { } impl Client { fn new(conn: Pin<Box<quiche::Connection>>, addr: &SocketAddr, id: ConnectionID) -> Client { fn new(conn: quiche::Connection, addr: &SocketAddr, id: ConnectionID) -> Client { Client { conn, h3_conn: None, Loading Loading
doh/connection/driver.rs +27 −15 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ use std::collections::HashMap; use std::default::Default; use std::future; use std::io; use std::pin::Pin; use thiserror::Error; use tokio::net::UdpSocket; use tokio::select; Loading Loading @@ -80,7 +79,7 @@ const MAX_UDP_PACKET_SIZE: usize = 65536; struct Driver { request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, // This buffer is large, boxing it will keep it // off the stack and prevent it being copied during Loading Loading @@ -119,7 +118,7 @@ async fn optional_timeout(timeout: Option<boot_time::Duration>, net_id: u32) { pub async fn drive( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Result<()> { Loading @@ -130,7 +129,7 @@ impl Driver { fn new( request_rx: mpsc::Receiver<Request>, status_tx: watch::Sender<Status>, quiche_conn: Pin<Box<quiche::Connection>>, quiche_conn: quiche::Connection, socket: UdpSocket, net_id: u32, ) -> Self { Loading Loading @@ -163,7 +162,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); let session = self.quiche_conn.session().map(<[_]>::to_vec); let _ = self.status_tx.send(Status::Dead { session }); Err(Error::Closed) } else { Ok(()) Loading @@ -180,7 +180,8 @@ impl Driver { self.quiche_conn.peer_error() ); // We don't care if the receiver has hung up let _ = self.status_tx.send(Status::Dead { session: self.quiche_conn.session() }); let session = self.quiche_conn.session().map(<[_]>::to_vec); let _ = self.status_tx.send(Status::Dead { session }); self.request_rx.close(); // Drain the pending DNS requests from the queue to make their corresponding future Loading Loading @@ -265,10 +266,8 @@ impl H3Driver { let _ = self.driver.status_tx.send(Status::H3); loop { if let Err(e) = self.drive_once().await { let _ = self .driver .status_tx .send(Status::Dead { session: self.driver.quiche_conn.session() }); let session = self.driver.quiche_conn.session().map(<[_]>::to_vec); let _ = self.driver.status_tx.send(Status::Dead { session }); return Err(e); } } Loading Loading @@ -445,17 +444,30 @@ impl H3Driver { ); self.respond(stream_id) } // This clause is for quiche 0.10.x, we're still on 0.9.x //h3::Event::Reset(e) => { // self.streams.get_mut(&stream_id).map(|stream| stream.error = Some(e)); // self.respond(stream_id); //} h3::Event::Reset(e) => { debug!( "process_h3_event: h3::Event::Reset with error code {} on stream ID {}, network {}", e, stream_id, self.driver.net_id ); if let Some(stream) = self.streams.get_mut(&stream_id) { stream.error = Some(e) } self.respond(stream_id); } h3::Event::Datagram => { warn!("Unexpected Datagram received"); // We don't care if something went wrong with the datagram, we didn't // want it anyways. let _ = self.discard_datagram(stream_id); } h3::Event::PriorityUpdate => { debug!( "process_h3_event: h3::Event::PriorityUpdate on stream ID {}, network {}", stream_id, self.driver.net_id ); // It tells us that PRIORITY_UPDATE frame is received, but we are not // using it in our code currently. No-op should be fine. } h3::Event::GoAway => self.shutdown(false, b"SERVER GOAWAY").await?, } Ok(()) Loading
doh/tests/doh_frontend/src/client.rs +2 −3 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ use log::{debug, error, info, warn}; use quiche::h3::NameValue; use std::collections::{hash_map, HashMap}; use std::net::SocketAddr; use std::pin::Pin; use std::time::Duration; pub const DNS_HEADER_SIZE: usize = 12; Loading @@ -35,7 +34,7 @@ const URL_PATH_PREFIX: &str = "/dns-query?dns="; /// Manages a QUIC and HTTP/3 connection. No socket I/O operations. pub struct Client { /// QUIC connection. conn: Pin<Box<quiche::Connection>>, conn: quiche::Connection, /// HTTP/3 connection. h3_conn: Option<quiche::h3::Connection>, Loading @@ -59,7 +58,7 @@ pub struct Client { } impl Client { fn new(conn: Pin<Box<quiche::Connection>>, addr: &SocketAddr, id: ConnectionID) -> Client { fn new(conn: quiche::Connection, addr: &SocketAddr, id: ConnectionID) -> Client { Client { conn, h3_conn: None, Loading