keepalive
This commit is contained in:
parent
616c17501a
commit
07ae82809e
1 changed files with 7 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ use http::HeaderLineIterator;
|
|||
use policy::{CompiledPolicies, Policy};
|
||||
|
||||
use rand::Rng;
|
||||
use realm_syscall::socket2::TcpKeepalive;
|
||||
use regex::bytes::Regex;
|
||||
use std::{io::Write, net::SocketAddr, time::Duration};
|
||||
use tokio::{
|
||||
|
|
@ -234,10 +235,15 @@ async fn main() {
|
|||
}
|
||||
|
||||
async fn do_proxy(pass_addr: SocketAddr, mut client_stream: TcpStream) {
|
||||
// TODO reuse connections
|
||||
let keepalive_dur = Duration::from_secs(15);
|
||||
let mut keepalive = TcpKeepalive::new().with_time(keepalive_dur);
|
||||
keepalive = TcpKeepalive::with_interval(keepalive, keepalive_dur);
|
||||
keepalive = TcpKeepalive::with_retries(keepalive, 3);
|
||||
|
||||
let pass_socket = realm_syscall::new_tcp_socket(&pass_addr).unwrap();
|
||||
|
||||
pass_socket.set_reuse_address(true).ok();
|
||||
pass_socket.set_tcp_keepalive(&keepalive).ok();
|
||||
|
||||
let pass_socket = TcpSocket::from_std_stream(pass_socket.into());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue