From b6322c42a148b39faea6da89322bdf8c6be3cfd4 Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Wed, 6 Jul 2022 08:29:38 +0900 Subject: [PATCH] fix log alt-svc --- src/constants.rs | 3 +++ src/proxy/proxy_handler.rs | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/constants.rs b/src/constants.rs index 30a8e48..45552b3 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -7,3 +7,6 @@ pub const MAX_CLIENTS: usize = 512; pub const MAX_CONCURRENT_STREAMS: u32 = 16; // #[cfg(feature = "tls")] pub const CERTS_WATCH_DELAY_SECS: u32 = 10; + +#[cfg(feature = "h3")] +pub const H3_ALT_SVC_MAX_AGE: u32 = 60; diff --git a/src/proxy/proxy_handler.rs b/src/proxy/proxy_handler.rs index cb3dfbe..a82d489 100644 --- a/src/proxy/proxy_handler.rs +++ b/src/proxy/proxy_handler.rs @@ -1,6 +1,6 @@ // Highly motivated by https://github.com/felipenoris/hyper-reverse-proxy use super::Proxy; -use crate::{error::*, log::*}; +use crate::{constants::*, error::*, log::*}; use hyper::{ client::connect::Connect, header::{HeaderMap, HeaderValue}, @@ -112,9 +112,15 @@ where { if self.globals.http3 { if let Some(port) = self.globals.https_port { - res_backend - .headers_mut() - .insert("alt-svc", format!("h3=\":{}\"", port).parse().unwrap()); + res_backend.headers_mut().insert( + hyper::header::ALT_SVC, + format!( + "h3=\":{}\"; ma={}, h3-29\":{}\"; ma={}", + port, H3_ALT_SVC_MAX_AGE, port, H3_ALT_SVC_MAX_AGE + ) + .parse() + .unwrap(), + ); } } }