Add rudimentary web server

This commit is contained in:
Jett Chen 2023-08-26 20:51:40 +08:00
parent 12e53a4b2a
commit a2cbd2ad77
6 changed files with 235 additions and 35 deletions

View file

@ -5,6 +5,9 @@ pub struct TunInterface {
inner: AsyncFd<crate::TunInterface>,
}
unsafe impl Send for TunInterface {
}
impl TunInterface {
pub fn new(tun: crate::TunInterface) -> io::Result<Self> {
Ok(Self {
@ -62,16 +65,6 @@ impl TunInterface {
}
}
pub async fn set_name(&self, name: &str) -> io::Result<()> {
loop {
let mut guard = self.inner.readable().await?;
match guard.try_io(|inner| inner.get_ref().set_name(name)) {
Ok(result) => return result,
Err(_would_block) => continue,
}
}
}
pub async fn netmask(&self) -> io::Result<std::net::Ipv4Addr> {
loop {
let mut guard = self.inner.readable().await?;