Fixed a number of warnings

This commit is contained in:
Conrad Kramer 2023-12-17 19:40:19 -08:00
parent 76278809ea
commit 104f8215ba
28 changed files with 144 additions and 199 deletions

View file

@ -26,7 +26,7 @@ async fn generate(out_dir: &std::path::Path) -> anyhow::Result<()> {
println!("cargo:rerun-if-changed={}", binary_path.to_str().unwrap());
if let (Ok(..), Ok(..)) = (File::open(&bindings_path), File::open(&binary_path)) {
return Ok(());
return Ok(())
};
let archive = download(out_dir)

View file

@ -34,7 +34,7 @@ impl TunInterface {
Ok(result) => return result,
Err(_would_block) => {
tracing::debug!("WouldBlock");
continue;
continue
}
}
}

View file

@ -1,6 +1,6 @@
use std::{
io::{Error, IoSlice},
mem::{self, ManuallyDrop},
mem,
net::{Ipv4Addr, SocketAddrV4},
os::fd::{AsRawFd, FromRawFd, RawFd},
};

View file

@ -2,11 +2,20 @@ use std::mem;
use libc::{c_char, c_int, c_short, c_uint, c_ulong, sockaddr};
pub use libc::{
c_void, sockaddr_ctl, sockaddr_in, socklen_t, AF_SYSTEM, AF_SYS_CONTROL, IFNAMSIZ,
c_void,
sockaddr_ctl,
sockaddr_in,
socklen_t,
AF_SYSTEM,
AF_SYS_CONTROL,
IFNAMSIZ,
SYSPROTO_CONTROL,
};
use nix::{
ioctl_read_bad, ioctl_readwrite, ioctl_write_ptr_bad, request_code_readwrite,
ioctl_read_bad,
ioctl_readwrite,
ioctl_write_ptr_bad,
request_code_readwrite,
request_code_write,
};

View file

@ -13,6 +13,7 @@ use fehler::throws;
use libc::in6_ifreq;
use socket2::{Domain, SockAddr, Socket, Type};
use tracing::{info, instrument};
use super::{ifname_to_string, string_to_ifname};
use crate::TunOptions;

View file

@ -1,5 +1,5 @@
use std::{
io::{Error, Read},
io::Error,
mem::MaybeUninit,
os::fd::{AsRawFd, FromRawFd, IntoRawFd, RawFd},
};
@ -51,7 +51,7 @@ impl TunInterface {
let mut tmp_buf = [MaybeUninit::uninit(); 1500];
let len = self.socket.recv(&mut tmp_buf)?;
let result_buf = unsafe { assume_init(&tmp_buf[4..len]) };
buf[..len - 4].copy_from_slice(&result_buf);
buf[..len - 4].copy_from_slice(result_buf);
len - 4
}

View file

@ -11,7 +11,7 @@ fn tst_read() {
// This test is interactive, you need to send a packet to any server through
// 192.168.1.10 EG. `sudo route add 8.8.8.8 192.168.1.10`,
//`dig @8.8.8.8 hackclub.com`
let mut tun = TunInterface::new()?;
let tun = TunInterface::new()?;
println!("tun name: {:?}", tun.name()?);
tun.set_ipv4_addr(Ipv4Addr::from([192, 168, 1, 10]))?;
println!("tun ip: {:?}", tun.ipv4_addr()?);