避免直接关闭网卡
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
use crate::error::Error;
|
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<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
pub mod channel;
|
pub mod channel;
|
||||||
|
|||||||
@@ -112,16 +112,17 @@ impl DeviceWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn close(&self) -> io::Result<()> {
|
pub fn close(&self) -> io::Result<()> {
|
||||||
unsafe {
|
//早期使用close直接切断网卡,现在并不需要这么做也能正常关闭
|
||||||
match &self.writer {
|
// unsafe {
|
||||||
DeviceW::Tun(writer) => {
|
// match &self.writer {
|
||||||
libc::close(writer.as_raw_fd());
|
// DeviceW::Tun(writer) => {
|
||||||
}
|
// libc::close(writer.as_raw_fd());
|
||||||
DeviceW::Tap((writer, _)) => {
|
// }
|
||||||
libc::close(writer.as_raw_fd());
|
// DeviceW::Tap((writer, _)) => {
|
||||||
}
|
// libc::close(writer.as_raw_fd());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub fn is_tun(&self) -> bool {
|
pub fn is_tun(&self) -> bool {
|
||||||
|
|||||||
@@ -29,5 +29,6 @@ features = [
|
|||||||
"winerror",
|
"winerror",
|
||||||
"ipexport",
|
"ipexport",
|
||||||
"iphlpapi",
|
"iphlpapi",
|
||||||
"handleapi"
|
"handleapi",
|
||||||
|
"ifdef"
|
||||||
]
|
]
|
||||||
@@ -119,7 +119,8 @@ impl TapDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn delete(self) -> io::Result<()> {
|
pub fn delete(self) -> io::Result<()> {
|
||||||
iface::delete_interface(&self.luid)
|
// iface::delete_interface(&self.luid)
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ pub struct Version {
|
|||||||
|
|
||||||
impl IFace for TunDevice {
|
impl IFace for TunDevice {
|
||||||
fn shutdown(&self) -> io::Result<()> {
|
fn shutdown(&self) -> io::Result<()> {
|
||||||
let _ = unsafe { synchapi::SetEvent(self.shutdown_event) };
|
// let _ = unsafe { synchapi::SetEvent(self.shutdown_event) };
|
||||||
let _ = unsafe { handleapi::CloseHandle(self.shutdown_event) };
|
// let _ = unsafe { handleapi::CloseHandle(self.shutdown_event) };
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user