diff --git a/vnt/src/lib.rs b/vnt/src/lib.rs index 11389e6..d219f57 100644 --- a/vnt/src/lib.rs +++ b/vnt/src/lib.rs @@ -1,5 +1,5 @@ use crate::error::Error; -pub const VNT_VERSION: &'static str = "1.2.4.3"; +pub const VNT_VERSION: &'static str = "1.2.4.4"; pub type Result = std::result::Result; pub mod channel; diff --git a/vnt/src/tun_tap_device/linux_mac.rs b/vnt/src/tun_tap_device/linux_mac.rs index 876ee02..1122f9e 100644 --- a/vnt/src/tun_tap_device/linux_mac.rs +++ b/vnt/src/tun_tap_device/linux_mac.rs @@ -112,16 +112,17 @@ impl DeviceWriter { } } pub fn close(&self) -> io::Result<()> { - unsafe { - match &self.writer { - DeviceW::Tun(writer) => { - libc::close(writer.as_raw_fd()); - } - DeviceW::Tap((writer, _)) => { - libc::close(writer.as_raw_fd()); - } - } - } + //早期使用close直接切断网卡,现在并不需要这么做也能正常关闭 + // unsafe { + // match &self.writer { + // DeviceW::Tun(writer) => { + // libc::close(writer.as_raw_fd()); + // } + // DeviceW::Tap((writer, _)) => { + // libc::close(writer.as_raw_fd()); + // } + // } + // } Ok(()) } pub fn is_tun(&self) -> bool { diff --git a/vnt/win-tun-tap/Cargo.toml b/vnt/win-tun-tap/Cargo.toml index b79742f..05a137b 100644 --- a/vnt/win-tun-tap/Cargo.toml +++ b/vnt/win-tun-tap/Cargo.toml @@ -29,5 +29,6 @@ features = [ "winerror", "ipexport", "iphlpapi", - "handleapi" + "handleapi", + "ifdef" ] \ No newline at end of file diff --git a/vnt/win-tun-tap/src/tap/mod.rs b/vnt/win-tun-tap/src/tap/mod.rs index 0eb3f91..823d7ec 100644 --- a/vnt/win-tun-tap/src/tap/mod.rs +++ b/vnt/win-tun-tap/src/tap/mod.rs @@ -119,7 +119,8 @@ impl TapDevice { } pub fn delete(self) -> io::Result<()> { - iface::delete_interface(&self.luid) + // iface::delete_interface(&self.luid) + Ok(()) } } diff --git a/vnt/win-tun-tap/src/tun/mod.rs b/vnt/win-tun-tap/src/tun/mod.rs index ccd350f..d68ba5e 100644 --- a/vnt/win-tun-tap/src/tun/mod.rs +++ b/vnt/win-tun-tap/src/tun/mod.rs @@ -193,8 +193,8 @@ pub struct Version { impl IFace for TunDevice { fn shutdown(&self) -> io::Result<()> { - let _ = unsafe { synchapi::SetEvent(self.shutdown_event) }; - let _ = unsafe { handleapi::CloseHandle(self.shutdown_event) }; + // let _ = unsafe { synchapi::SetEvent(self.shutdown_event) }; + // let _ = unsafe { handleapi::CloseHandle(self.shutdown_event) }; Ok(()) }