From bc7bf5be43491bfce03f0d29f97137384a4de7a1 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Thu, 7 Nov 2024 21:11:56 +0100 Subject: [PATCH] tiem out when client too slow --- Cargo.toml | 2 +- src/server.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d4adbd2..3d2a1d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "revpfw3" repository = "https://github.com/tudbut/revpfw3" description = "A tool to bypass portforwarding restrictions using some cheap VServer" license = "MIT" -version = "0.4.0" +version = "0.4.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/server.rs b/src/server.rs index 1588a09..0ecca7c 100644 --- a/src/server.rs +++ b/src/server.rs @@ -39,6 +39,9 @@ pub fn server(port: u16, key: &str, sleep_delay_ms: u64) { let tcpl = TcpListener::bind(("0.0.0.0", port)).unwrap(); let mut tcp = loop { let Ok(mut tcp) = tcpl.accept() else { continue }; + tcp.0 + .set_read_timeout(Some(Duration::from_secs(5))) + .unwrap(); let Ok(()) = tcp.0.read_exact(&mut buf4) else { tcp.0.shutdown(Shutdown::Both).unwrap(); continue;