time out when client too slow

This commit is contained in:
Daniella 2024-11-07 21:11:56 +01:00
parent 135cc71df0
commit 18eb357092
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 4 additions and 1 deletions

View file

@ -3,7 +3,7 @@ name = "revpfw3"
repository = "https://github.com/tudbut/revpfw3" repository = "https://github.com/tudbut/revpfw3"
description = "A tool to bypass portforwarding restrictions using some cheap VServer" description = "A tool to bypass portforwarding restrictions using some cheap VServer"
license = "MIT" license = "MIT"
version = "0.4.2" version = "0.4.3"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -39,6 +39,9 @@ pub fn server(port: u16, key: &str, sleep_delay_ms: u64) {
let tcpl = TcpListener::bind(("::0", port)).unwrap(); let tcpl = TcpListener::bind(("::0", port)).unwrap();
let mut tcp = loop { let mut tcp = loop {
let Ok(mut tcp) = tcpl.accept() else { continue }; 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 { let Ok(()) = tcp.0.read_exact(&mut buf4) else {
tcp.0.shutdown(Shutdown::Both).unwrap(); tcp.0.shutdown(Shutdown::Both).unwrap();
continue; continue;