network: implement TCP proxy NAT via smoltcp

This commit is contained in:
Alex Zenla
2024-02-11 10:07:47 +00:00
parent 2c7879ad45
commit b9dadc6f37
9 changed files with 474 additions and 22 deletions

View File

@ -10,8 +10,10 @@ use crate::proxynat::udp::ProxyUdpHandler;
use crate::nat::{NatHandler, NatHandlerFactory, NatKeyProtocol};
use self::icmp::ProxyIcmpHandler;
use self::tcp::ProxyTcpHandler;
mod icmp;
mod tcp;
mod udp;
pub struct ProxyNatHandlerFactory {}
@ -56,7 +58,17 @@ impl NatHandlerFactory for ProxyNatHandlerFactory {
}
}
_ => None,
NatKeyProtocol::Tcp => {
let (rx_sender, rx_receiver) = channel::<Vec<u8>>(4);
let mut handler = ProxyTcpHandler::new(rx_sender);
if let Err(error) = handler.spawn(context, rx_receiver).await {
warn!("unable to spawn tcp proxy handler: {}", error);
None
} else {
Some(Box::new(handler))
}
}
}
}
}