Fix async problem
remove timeouts
This commit is contained in:
parent
28ebfec3ca
commit
7f6897f0d6
3 changed files with 6 additions and 14 deletions
|
|
@ -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=")?;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ impl TunInterface {
|
|||
|
||||
#[throws]
|
||||
#[instrument]
|
||||
pub fn set_timeout(&self, timeout: Option<std::time::Duration>) {
|
||||
self.socket.set_read_timeout(timeout)?;
|
||||
pub fn set_nonblocking(&mut self, nb: bool) {
|
||||
self.socket.set_nonblocking(nb)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue