fix some bugs, improve speed with multiple connections
This commit is contained in:
parent
103bcf7412
commit
58bb1d58c6
5 changed files with 9 additions and 7 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -72,7 +72,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "revpfw3"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"enum-ordinalize",
|
||||
]
|
||||
|
|
|
@ -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.3.0"
|
||||
version = "0.3.1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
|
@ -69,6 +69,7 @@ pub fn client(ip: &str, port: u16, dest_ip: &str, dest_port: u16, key: &str, sle
|
|||
.unwrap();
|
||||
tcp.write(&i.to_be_bytes()).unwrap();
|
||||
tcp.write(&x.to_be_bytes()).unwrap();
|
||||
socket.punish(x);
|
||||
}
|
||||
}
|
||||
for i in to_remove.into_iter().rev() {
|
||||
|
|
|
@ -92,6 +92,7 @@ pub fn server(port: u16, key: &str, sleep_delay_ms: u64) {
|
|||
.unwrap();
|
||||
tcp.write(&i.to_be_bytes()).unwrap();
|
||||
tcp.write(&x.to_be_bytes()).unwrap();
|
||||
socket.punish(x);
|
||||
}
|
||||
}
|
||||
for i in to_remove.into_iter().rev() {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{
|
|||
io::{Error, Read},
|
||||
io::{ErrorKind, Write},
|
||||
net::TcpStream,
|
||||
time::SystemTime,
|
||||
time::{SystemTime, Duration},
|
||||
};
|
||||
|
||||
use crate::io_sync;
|
||||
|
@ -73,7 +73,7 @@ impl SocketAdapter {
|
|||
self.written = 0;
|
||||
self.to_write = buf.len();
|
||||
self.write[..buf.len()].copy_from_slice(buf);
|
||||
self.accumulated_delay += sa.elapsed().unwrap().as_millis();
|
||||
self.accumulated_delay += sa.elapsed().unwrap().as_micros();
|
||||
return Ok(());
|
||||
};
|
||||
x.copy_from_slice(buf);
|
||||
|
@ -87,7 +87,7 @@ impl SocketAdapter {
|
|||
}
|
||||
|
||||
pub fn update(&mut self) -> Result<(), Error> {
|
||||
if Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_millis()) < self.ignore_until {
|
||||
if Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros()) < self.ignore_until {
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(ref x) = self.broken {
|
||||
|
@ -121,7 +121,7 @@ impl SocketAdapter {
|
|||
}
|
||||
|
||||
pub fn poll(&mut self, buf: &mut [u8]) -> Result<Option<usize>, Error> {
|
||||
if Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_millis()) < self.ignore_until {
|
||||
if Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros()) < self.ignore_until {
|
||||
return Ok(None);
|
||||
}
|
||||
self.update()?;
|
||||
|
@ -134,7 +134,7 @@ impl SocketAdapter {
|
|||
|
||||
pub fn punish(&mut self, time: u128) {
|
||||
if self.ignore_until == None {
|
||||
self.ignore_until = Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_millis());
|
||||
self.ignore_until = Some(SystemTime::UNIX_EPOCH.elapsed().unwrap().as_micros());
|
||||
}
|
||||
self.ignore_until = self.ignore_until.map(|x| x + time);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue