Fix async problem

remove timeouts
This commit is contained in:
Jett Chen 2023-12-03 01:27:06 +08:00
parent 28ebfec3ca
commit 7f6897f0d6
3 changed files with 6 additions and 14 deletions

View file

@ -47,7 +47,7 @@ pub async fn daemon_main() -> Result<()> {
let mut _tun = tun::TunInterface::new()?;
_tun.set_ipv4_addr(Ipv4Addr::from([192, 168, 1, 10]))?;
_tun.set_timeout(Some(std::time::Duration::from_millis(10)))?;
_tun.set_nonblocking(true)?;
let tun = tun::tokio::TunInterface::new(_tun)?;
let private_key = parse_secret_key("GNqIAOCRxjl/cicZyvkvpTklgQuUmGUIEkH7IXF/sEE=")?;

View file

@ -74,20 +74,12 @@ impl PeerPcb {
};
let mut res_buf = [0;1500];
// log::debug!("{} : waiting for readability on {:?}", rid, socket);
match timeout(Duration::from_millis(10), socket.readable()).await {
let len = match socket.recv(&mut res_buf).await {
Ok(l) => {l}
Err(e) => {
// log::debug!("{}: timeout waiting for readability on {:?}", rid, e);
log::error!("{}: error reading from socket: {:?}", rid, e);
continue
}
Ok(Err(e)) => {
log::debug!("{}: error waiting for readability on {:?}", rid, e);
continue
}
Ok(Ok(_)) => {}
};
log::debug!("{}: readable!", rid);
let Ok(len) = socket.try_recv(&mut res_buf) else {
continue
};
let mut res_dat = &res_buf[..len];
tracing::debug!("{}: Decapsulating {} bytes", rid, len);