mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
add keepalive option for quic proxy (#1008)
avoid connection loss when idle
This commit is contained in:
@@ -2,14 +2,17 @@
|
|||||||
//!
|
//!
|
||||||
//! Checkout the `README.md` for guidance.
|
//! Checkout the `README.md` for guidance.
|
||||||
|
|
||||||
use std::{error::Error, net::SocketAddr, sync::Arc};
|
use std::{error::Error, net::SocketAddr, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use crate::tunnel::{
|
use crate::tunnel::{
|
||||||
common::{FramedReader, FramedWriter, TunnelWrapper},
|
common::{FramedReader, FramedWriter, TunnelWrapper},
|
||||||
TunnelInfo,
|
TunnelInfo,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use quinn::{crypto::rustls::QuicClientConfig, ClientConfig, Connection, Endpoint, ServerConfig};
|
use quinn::{
|
||||||
|
crypto::rustls::QuicClientConfig, ClientConfig, Connection, Endpoint, ServerConfig,
|
||||||
|
TransportConfig,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
check_scheme_and_get_socket_addr,
|
check_scheme_and_get_socket_addr,
|
||||||
@@ -18,9 +21,15 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub fn configure_client() -> ClientConfig {
|
pub fn configure_client() -> ClientConfig {
|
||||||
ClientConfig::new(Arc::new(
|
let mut tspt_cfg = TransportConfig::default();
|
||||||
|
tspt_cfg.keep_alive_interval(Some(Duration::from_secs(5)));
|
||||||
|
|
||||||
|
let mut cfg = ClientConfig::new(Arc::new(
|
||||||
QuicClientConfig::try_from(get_insecure_tls_client_config()).unwrap(),
|
QuicClientConfig::try_from(get_insecure_tls_client_config()).unwrap(),
|
||||||
))
|
));
|
||||||
|
cfg.transport_config(Arc::new(tspt_cfg));
|
||||||
|
|
||||||
|
cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a QUIC endpoint configured to listen for incoming connections on a certain address
|
/// Constructs a QUIC endpoint configured to listen for incoming connections on a certain address
|
||||||
|
|||||||
Reference in New Issue
Block a user