merge main into boringtun-merge

This commit is contained in:
Jett Chen 2023-11-08 19:15:42 +08:00
parent 759311e4f4
commit f1649ce3b2
39 changed files with 3145 additions and 239 deletions

View file

@ -1,16 +1,18 @@
use std::{
fs::OpenOptions,
io::{Error, Write},
mem,
net::{Ipv4Addr, Ipv6Addr, SocketAddrV4},
os::{
fd::RawFd,
unix::io::{AsRawFd, FromRawFd, IntoRawFd},
},
};
use fehler::throws;
use socket2::{Domain, SockAddr, Socket, Type};
use std::fs::OpenOptions;
use std::io::{Error, Write};
use std::mem;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4};
use std::os::fd::RawFd;
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
use tracing::{info, instrument};
use libc::in6_ifreq;
use socket2::{Domain, SockAddr, Socket, Type};
use tracing::{info, instrument};
use super::{ifname_to_string, string_to_ifname, TunOptions};
@ -24,9 +26,7 @@ pub struct TunInterface {
impl TunInterface {
#[throws]
#[instrument]
pub fn new() -> TunInterface {
Self::new_with_options(TunOptions::new())?
}
pub fn new() -> TunInterface { Self::new_with_options(TunOptions::new())? }
#[throws]
#[instrument]
@ -212,7 +212,5 @@ impl TunInterface {
#[throws]
#[instrument]
pub fn send(&self, buf: &[u8]) -> usize {
self.socket.send(buf)?
}
pub fn send(&self, buf: &[u8]) -> usize { self.socket.send(buf)? }
}

View file

@ -1,10 +1,7 @@
use nix::{ioctl_read_bad, ioctl_write_ptr_bad, request_code_read, request_code_write};
use std::mem::size_of;
pub use libc::ifreq;
pub use libc::sockaddr;
pub use libc::sockaddr_in;
pub use libc::sockaddr_in6;
pub use libc::{ifreq, sockaddr, sockaddr_in, sockaddr_in6};
use nix::{ioctl_read_bad, ioctl_write_ptr_bad, request_code_read, request_code_write};
ioctl_write_ptr_bad!(
tun_set_iff,