aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-03-17 20:58:45 +0100
committermetamuffin <metamuffin@disroot.org>2025-03-17 20:58:45 +0100
commit73768c25588779bce122c0e3daa023024e972298 (patch)
tree50d88a2dc201a0da787c2be4d0f762568debf647
parent143fe969eb6225c2aa8694930114103f1d4f0c9c (diff)
downloadgnix-73768c25588779bce122c0e3daa023024e972298.tar
gnix-73768c25588779bce122c0e3daa023024e972298.tar.bz2
gnix-73768c25588779bce122c0e3daa023024e972298.tar.zst
disable h3 option
-rw-r--r--src/config.rs2
-rw-r--r--src/main.rs16
2 files changed, 10 insertions, 8 deletions
diff --git a/src/config.rs b/src/config.rs
index 196b489..bc972e3 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -62,6 +62,8 @@ pub struct HttpsConfig {
#[serde(deserialize_with = "seq_or_not")]
pub cert_path: Vec<PathBuf>,
pub cert_fallback: Option<PathBuf>,
+ #[serde(default)]
+ pub disable_h3: bool,
}
// try deser Vec<T> but fall back to deser T and putting that in Vec
diff --git a/src/main.rs b/src/main.rs
index de43a6b..08f306d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -203,6 +203,9 @@ async fn serve_h3(state: Arc<State>) -> Result<()> {
Some(n) => n,
None => return Ok(()),
};
+ if https_config.disable_h3 {
+ return Ok(());
+ }
let bind_addrs = https_config.bind.clone();
let certs = CertPool::load(&https_config.cert_path, https_config.cert_fallback.clone())?;
let mut cfg = rustls::ServerConfig::builder()
@@ -216,7 +219,7 @@ async fn serve_h3(state: Arc<State>) -> Result<()> {
let cfg = quinn::ServerConfig::with_crypto(cfg.clone());
let endpoint = quinn::Endpoint::server(cfg, *listen_addr)?;
let listen_addr = *listen_addr;
- info!("HTTPS (HTTP/3) listener bound to {listen_addr}");
+ info!("HTTPS (h3) listener bound to {listen_addr}");
while let Some(conn) = endpoint.accept().await {
let state = state.clone();
tokio::spawn(async move {
@@ -288,13 +291,10 @@ async fn serve_h3(state: Arc<State>) -> Result<()> {
}
}
Ok(None) => break,
- Err(e) => {
- warn!("h3 error: {e}");
- match e.get_error_level() {
- ErrorLevel::ConnectionError => break,
- ErrorLevel::StreamError => continue,
- }
- }
+ Err(e) => match e.get_error_level() {
+ ErrorLevel::ConnectionError => break,
+ ErrorLevel::StreamError => continue,
+ },
}
}
drop(_sem);