mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-23 15:29:10 +00:00
fix memory exhaustion
This commit is contained in:
parent
81db9cb181
commit
2c9ac6f3a9
1 changed files with 6 additions and 0 deletions
|
@ -174,6 +174,7 @@ const CLIENT_WRITE_CLOSED: u8 = 2;
|
|||
|
||||
const UDP_ASSO_TIMEOUT: u64 = 10; // seconds
|
||||
const DNS_PORT: u16 = 53;
|
||||
const IP_PACKAGE_MAX_SIZE: usize = 0xFFFF;
|
||||
|
||||
struct ConnectionState {
|
||||
smoltcp_handle: SocketHandle,
|
||||
|
@ -436,6 +437,11 @@ impl<'a> TunToProxy<'a> {
|
|||
let socket = self.sockets.get_mut::<tcp::Socket>(state.smoltcp_handle);
|
||||
let mut error = Ok(());
|
||||
while socket.can_recv() && error.is_ok() {
|
||||
let dir = Direction::Outgoing(OutgoingDirection::ToServer);
|
||||
if state.proxy_handler.data_len(dir) >= IP_PACKAGE_MAX_SIZE {
|
||||
break;
|
||||
}
|
||||
|
||||
socket.recv(|data| {
|
||||
let event = IncomingDataEvent {
|
||||
direction: IncomingDirection::FromClient,
|
||||
|
|
Loading…
Add table
Reference in a new issue