checkpoint
This commit is contained in:
parent
ede0d13bca
commit
db1750a045
39 changed files with 514 additions and 359 deletions
|
|
@ -9,11 +9,12 @@ use byteorder::{ByteOrder, NetworkEndian};
|
|||
use fehler::throws;
|
||||
use libc::{c_char, iovec, writev, AF_INET, AF_INET6};
|
||||
use socket2::{Domain, SockAddr, Socket, Type};
|
||||
use tracing::{self, instrument};
|
||||
use tracing::{self, debug, instrument};
|
||||
|
||||
mod kern_control;
|
||||
mod sys;
|
||||
pub mod sys;
|
||||
|
||||
use crate::retrieve;
|
||||
use kern_control::SysControlSocket;
|
||||
|
||||
pub use super::queue::TunQueue;
|
||||
|
|
@ -34,8 +35,13 @@ impl TunInterface {
|
|||
#[throws]
|
||||
#[instrument]
|
||||
pub fn new_with_options(options: TunOptions) -> TunInterface {
|
||||
let ti = TunInterface::connect(0)?;
|
||||
if let Some(addr) = options.address{
|
||||
debug!("Opening tun interface with options: {:?}", &options);
|
||||
let ti = if let Some(n) = options.seek_utun {
|
||||
retrieve().ok_or(Error::new(std::io::ErrorKind::NotFound, "No utun found"))?
|
||||
} else {
|
||||
TunInterface::connect(0)?
|
||||
};
|
||||
if let Some(addr) = options.address {
|
||||
if let Ok(addr) = addr.parse() {
|
||||
ti.set_ipv4_addr(addr)?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue