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]]
|
[[package]]
|
||||||
name = "revpfw3"
|
name = "revpfw3"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-ordinalize",
|
"enum-ordinalize",
|
||||||
]
|
]
|
||||||
|
|
|
@ -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.3.0"
|
version = "0.3.1"
|
||||||
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
|
||||||
|
|
|
@ -69,6 +69,7 @@ pub fn client(ip: &str, port: u16, dest_ip: &str, dest_port: u16, key: &str, sle
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tcp.write(&i.to_be_bytes()).unwrap();
|
tcp.write(&i.to_be_bytes()).unwrap();
|
||||||
tcp.write(&x.to_be_bytes()).unwrap();
|
tcp.write(&x.to_be_bytes()).unwrap();
|
||||||
|
socket.punish(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i in to_remove.into_iter().rev() {
|
for i in to_remove.into_iter().rev() {
|
||||||
|
|
|
@ -92,6 +92,7 @@ pub fn server(port: u16, key: &str, sleep_delay_ms: u64) {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tcp.write(&i.to_be_bytes()).unwrap();
|
tcp.write(&i.to_be_bytes()).unwrap();
|
||||||
tcp.write(&x.to_be_bytes()).unwrap();
|
tcp.write(&x.to_be_bytes()).unwrap();
|
||||||
|
socket.punish(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i in to_remove.into_iter().rev() {
|
for i in to_remove.into_iter().rev() {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{
|
||||||
io::{Error, Read},
|
io::{Error, Read},
|
||||||
io::{ErrorKind, Write},
|
io::{ErrorKind, Write},
|
||||||
net::TcpStream,
|
net::TcpStream,
|
||||||
time::SystemTime,
|
time::{SystemTime, Duration},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::io_sync;
|
use crate::io_sync;
|
||||||
|
@ -73,7 +73,7 @@ impl SocketAdapter {
|
||||||
self.written = 0;
|
self.written = 0;
|
||||||
self.to_write = buf.len();
|
self.to_write = buf.len();
|
||||||
self.write[..buf.len()].copy_from_slice(buf);
|
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(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
x.copy_from_slice(buf);
|
x.copy_from_slice(buf);
|
||||||
|
@ -87,7 +87,7 @@ impl SocketAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self) -> Result<(), Error> {
|
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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if let Some(ref x) = self.broken {
|
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> {
|
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);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
self.update()?;
|
self.update()?;
|
||||||
|
@ -134,7 +134,7 @@ impl SocketAdapter {
|
||||||
|
|
||||||
pub fn punish(&mut self, time: u128) {
|
pub fn punish(&mut self, time: u128) {
|
||||||
if self.ignore_until == None {
|
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);
|
self.ignore_until = self.ignore_until.map(|x| x + time);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue