fix log alt-svc

This commit is contained in:
Jun Kurihara 2022-07-06 08:29:38 +09:00
commit b6322c42a1
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
2 changed files with 13 additions and 4 deletions

View file

@ -7,3 +7,6 @@ pub const MAX_CLIENTS: usize = 512;
pub const MAX_CONCURRENT_STREAMS: u32 = 16; pub const MAX_CONCURRENT_STREAMS: u32 = 16;
// #[cfg(feature = "tls")] // #[cfg(feature = "tls")]
pub const CERTS_WATCH_DELAY_SECS: u32 = 10; pub const CERTS_WATCH_DELAY_SECS: u32 = 10;
#[cfg(feature = "h3")]
pub const H3_ALT_SVC_MAX_AGE: u32 = 60;

View file

@ -1,6 +1,6 @@
// Highly motivated by https://github.com/felipenoris/hyper-reverse-proxy // Highly motivated by https://github.com/felipenoris/hyper-reverse-proxy
use super::Proxy; use super::Proxy;
use crate::{error::*, log::*}; use crate::{constants::*, error::*, log::*};
use hyper::{ use hyper::{
client::connect::Connect, client::connect::Connect,
header::{HeaderMap, HeaderValue}, header::{HeaderMap, HeaderValue},
@ -112,9 +112,15 @@ where
{ {
if self.globals.http3 { if self.globals.http3 {
if let Some(port) = self.globals.https_port { if let Some(port) = self.globals.https_port {
res_backend res_backend.headers_mut().insert(
.headers_mut() hyper::header::ALT_SVC,
.insert("alt-svc", format!("h3=\":{}\"", port).parse().unwrap()); format!(
"h3=\":{}\"; ma={}, h3-29\":{}\"; ma={}",
port, H3_ALT_SVC_MAX_AGE, port, H3_ALT_SVC_MAX_AGE
)
.parse()
.unwrap(),
);
} }
} }
} }