incorporate wireguard daemon with network interface

This commit is contained in:
Jett Chen 2023-11-09 08:08:09 +08:00
parent 6339b6bc4b
commit cdc3acdb5e
3 changed files with 25 additions and 8 deletions

View file

@ -44,7 +44,11 @@ impl TunInterface {
#[throws]
#[instrument]
pub fn recv(&mut self, buf: &mut [u8]) -> usize {
self.socket.read(buf)?
// there might be a more efficient way to implement this
let tmp_buf = &mut [0u8; 1500];
let len = self.socket.read(tmp_buf)?;
buf[..len-4].copy_from_slice(&tmp_buf[4..len]);
len-4
}
}