From ebf8337ad7d8e845a7cc6d15fa0013e8695f15c8 Mon Sep 17 00:00:00 2001 From: lbl <1791778603@qq.com> Date: Thu, 6 Feb 2025 16:26:47 +0800 Subject: [PATCH] default tun name use vnt-tun --- vnt/src/tun_tap_device/create_device.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vnt/src/tun_tap_device/create_device.rs b/vnt/src/tun_tap_device/create_device.rs index 046d91a..c57a161 100644 --- a/vnt/src/tun_tap_device/create_device.rs +++ b/vnt/src/tun_tap_device/create_device.rs @@ -59,14 +59,19 @@ fn create_device0(config: &DeviceConfig) -> io::Result> { tun_config .address_with_prefix(config.virtual_ip, netmask.count_ones() as u8) .up(); + + match &config.device_name { + None => { + #[cfg(any(target_os = "windows", target_os = "linux"))] + tun_config.name(DEFAULT_TUN_NAME); + } + Some(name) => { + tun_config.name(name); + } + } + #[cfg(target_os = "windows")] { - tun_config.name( - config - .device_name - .clone() - .unwrap_or(DEFAULT_TUN_NAME.to_string()), - ); tun_config.platform_config(|v| { v.metric(0).ring_capacity(4 * 1024 * 1024); });