提示创建tun失败的信息
This commit is contained in:
+8
-2
@@ -326,7 +326,7 @@ fn main() {
|
||||
Ok(config) => config,
|
||||
Err(e) => {
|
||||
println!("config.toml error: {}", e);
|
||||
return;
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
(config, cmd)
|
||||
@@ -353,7 +353,13 @@ fn main0(config: Config, _show_cmd: bool) {
|
||||
println!("UDP port mapping {}->{}", addr, dest)
|
||||
}
|
||||
}
|
||||
let vnt_util = Vnt::new(config, callback::VntHandler {}).unwrap();
|
||||
let vnt_util = match Vnt::new(config, callback::VntHandler {}) {
|
||||
Ok(vnt) => vnt,
|
||||
Err(e) => {
|
||||
println!("error: {:?}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
{
|
||||
let vnt_c = vnt_util.clone();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use anyhow::Context;
|
||||
use std::collections::HashMap;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::Arc;
|
||||
@@ -133,9 +134,12 @@ impl Vnt {
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
let device = {
|
||||
log::info!("开始创建tun");
|
||||
let device = tun_tap_device::create_device(&config)?;
|
||||
let device = tun_tap_device::create_device(&config).context("create tun failed")?;
|
||||
log::info!("创建tun成功");
|
||||
let tun_info = DeviceInfo::new(device.name()?, device.version()?);
|
||||
let tun_info = DeviceInfo::new(
|
||||
device.name().unwrap_or("unknown".into()),
|
||||
device.version().unwrap_or("unknown".into()),
|
||||
);
|
||||
log::info!("tun信息{:?}", tun_info);
|
||||
callback.create_tun(tun_info);
|
||||
device
|
||||
|
||||
Reference in New Issue
Block a user