allow to turn off forced connection timeout

This commit is contained in:
Jun Kurihara 2024-02-01 18:07:41 +09:00
commit b2b3b05fcb
No known key found for this signature in database
GPG key ID: 48ADFD173ED22B03
9 changed files with 41 additions and 19 deletions

View file

@ -1,6 +1,5 @@
use super::proxy_main::Proxy;
use crate::{
constants::CONNECTION_TIMEOUT_SEC,
crypto::CryptoSource,
error::*,
hyper_ext::body::{IncomingLike, RequestBody},
@ -11,7 +10,7 @@ use bytes::{Buf, Bytes};
use http::{Request, Response};
use http_body_util::BodyExt;
use hyper_util::client::legacy::connect::Connect;
use std::{net::SocketAddr, time::Duration};
use std::net::SocketAddr;
#[cfg(feature = "http3-quinn")]
use h3::{quic::BidiStream, quic::Connection as ConnectionQuic, server::RequestStream};
@ -72,7 +71,7 @@ where
let tls_server_name_inner = tls_server_name.clone();
self.globals.runtime_handle.spawn(async move {
if let Err(e) = tokio::time::timeout(
Duration::from_secs(CONNECTION_TIMEOUT_SEC + 1), // just in case...
self_inner.globals.proxy_config.connection_handling_timeout,
self_inner.h3_serve_stream(req, stream, client_addr, tls_server_name_inner),
)
.await

View file

@ -1,6 +1,6 @@
use super::socket::bind_tcp_socket;
use crate::{
constants::{CONNECTION_TIMEOUT_SEC, TLS_HANDSHAKE_TIMEOUT_SEC},
constants::TLS_HANDSHAKE_TIMEOUT_SEC,
crypto::{CryptoSource, ServerCrypto, SniServerCryptoMap},
error::*,
globals::Globals,
@ -88,9 +88,11 @@ where
let message_handler_clone = self.message_handler.clone();
let tls_enabled = self.tls_enabled;
let listening_on = self.listening_on;
let handling_timeout = self.globals.proxy_config.connection_handling_timeout;
self.globals.runtime_handle.clone().spawn(async move {
timeout(
Duration::from_secs(CONNECTION_TIMEOUT_SEC) + Duration::from_secs(1), // just in case...
handling_timeout,
server_clone.serve_connection_with_upgrades(
stream,
service_fn(move |req: Request<Incoming>| {