Start Tun Interface at Daemon Command

This commit is contained in:
Jett Chen 2023-12-09 20:13:49 +08:00
parent 347b78453f
commit ede0d13bca
9 changed files with 83 additions and 52 deletions

View file

@ -33,8 +33,14 @@ impl TunInterface {
#[throws]
#[instrument]
pub fn new_with_options(_: TunOptions) -> TunInterface {
TunInterface::connect(0)?
pub fn new_with_options(options: TunOptions) -> TunInterface {
let ti = TunInterface::connect(0)?;
if let Some(addr) = options.address{
if let Ok(addr) = addr.parse() {
ti.set_ipv4_addr(addr)?;
}
}
ti
}
#[throws]