diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/error.rs | 4 | ||||
-rw-r--r-- | src/h3_support.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 16 | ||||
-rw-r--r-- | src/modules/auth/openid.rs | 3 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/error.rs b/src/error.rs index 4237a5e..3d5d1aa 100644 --- a/src/error.rs +++ b/src/error.rs @@ -14,7 +14,7 @@ pub enum ServiceError { #[error("hyper error: {0}")] Hyper(hyper::Error), #[error("h3 error: {0}")] - H3(h3::Error), + H3Stream(h3::error::StreamError), #[error("host header missing")] NoHost, #[error("unknown host")] @@ -71,7 +71,7 @@ impl ServiceError { ServiceError::RequestTaken => StatusCode::INTERNAL_SERVER_ERROR, ServiceError::Limit(_) => StatusCode::TOO_MANY_REQUESTS, ServiceError::Hyper(_) => StatusCode::INTERNAL_SERVER_ERROR, - ServiceError::H3(_) => StatusCode::INTERNAL_SERVER_ERROR, + ServiceError::H3Stream(_) => StatusCode::INTERNAL_SERVER_ERROR, ServiceError::NoHost => StatusCode::BAD_REQUEST, ServiceError::UnknownHost => StatusCode::NOT_FOUND, ServiceError::UnknownPath => StatusCode::NOT_FOUND, diff --git a/src/h3_support.rs b/src/h3_support.rs index 9c17c25..c3e8866 100644 --- a/src/h3_support.rs +++ b/src/h3_support.rs @@ -28,7 +28,7 @@ impl Body for H3RequestBody { Poll::Ready(Some(Ok(Frame::data(f.copy_to_bytes(f.remaining()))))) } Poll::Ready(Ok(None)) => Poll::Ready(None), - Poll::Ready(Err(e)) => Poll::Ready(Some(Err(ServiceError::H3(e)))), + Poll::Ready(Err(e)) => Poll::Ready(Some(Err(ServiceError::H3Stream(e)))), Poll::Pending => Poll::Pending, } } diff --git a/src/main.rs b/src/main.rs index 356b270..00e4e5b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ use certs::CertPool; use config::{setup_file_watch, Config, NODE_KINDS}; use error::ServiceError; use futures::future::try_join_all; -use h3::{error::ErrorLevel, server::RequestStream}; +use h3::server::RequestStream; use h3_quinn::SendStream; use h3_support::H3RequestBody; use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING}; @@ -311,7 +311,11 @@ async fn serve_h3_stream( let max_par_requests = Semaphore::new(config.limits.max_requests_per_connnection); loop { match conn.accept().await { - Ok(Some((req, stream))) => { + Ok(Some(x)) => { + let Ok((req, stream)) = x.resolve_request().await else { + warn!("h3 request accept failed"); + continue; + }; let Ok(_sem_req) = max_par_requests.acquire().await else { warn!("h3 par request semasphore closed"); return; @@ -330,10 +334,10 @@ async fn serve_h3_stream( drop(_sem_req) } Ok(None) => break, - Err(e) => match e.get_error_level() { - ErrorLevel::ConnectionError => break, - ErrorLevel::StreamError => continue, - }, + Err(e) => { + warn!("h3 connection error: {e}"); + break; + } } } drop(_sem); diff --git a/src/modules/auth/openid.rs b/src/modules/auth/openid.rs index 9ea268c..0b5aea7 100644 --- a/src/modules/auth/openid.rs +++ b/src/modules/auth/openid.rs @@ -29,13 +29,12 @@ use percent_encoding::{ percent_decode, percent_decode_str, percent_encode, utf8_percent_encode, NON_ALPHANUMERIC, }; use rand::random; -use rustls::RootCertStore; +use rustls::{pki_types::ServerName, RootCertStore}; use serde::Deserialize; use serde_yml::Value; use sha2::{Digest, Sha256}; use std::{collections::HashSet, io::Read, pin::Pin, str::FromStr, sync::Arc, time::SystemTime}; use tokio::net::TcpStream; -use webpki::types::ServerName; pub struct OpenIDAuthKind; impl NodeKind for OpenIDAuthKind { |