From 885bde990a4d9acac9b5ff5382027001551c30df Mon Sep 17 00:00:00 2001 From: ssrlive <30760636+ssrlive@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:08:34 +0800 Subject: [PATCH] re-format code --- Cargo.toml | 45 ++++++++++++++++++------------------ src/platform/linux/device.rs | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 08d0af6a..e7826056 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,25 @@ license = "WTFPL" description = "TUN device creation and handling." repository = "https://github.com/meh/rust-tun" keywords = ["tun", "network", "tunnel", "bindings"] +rust-version = "1.77" + +[package.metadata.docs.rs] +all-features = true [lib] crate-type = ["staticlib", "cdylib", "lib"] +[features] +default = [] +# default = ["async"] +async = [ + "tokio", + "futures-core", + "futures", + "tokio-util", + "wintun-bindings/async", +] + [dependencies] bytes = { version = "1" } cfg-if = "1" @@ -25,6 +40,14 @@ tokio = { version = "1", features = [ ], optional = true } tokio-util = { version = "0.7", features = ["codec"], optional = true } +[dev-dependencies] +ctrlc2 = { version = "3", features = ["tokio", "termination"] } +env_logger = "0.11" +futures = "0.3" +packet = "0.1" +serde_json = "1" +tokio = { version = "1", features = ["rt-multi-thread"] } + [target.'cfg(unix)'.dependencies] nix = { version = "0.29", features = ["ioctl"] } @@ -48,28 +71,6 @@ wintun-bindings = { version = "^0.7.7", features = [ [target.'cfg(any(target_os = "macos", target_os = "freebsd"))'.dependencies] ipnet = "2" -[dev-dependencies] -ctrlc2 = { version = "3", features = ["tokio", "termination"] } -env_logger = "0.11" -futures = "0.3" -packet = "0.1" -serde_json = "1" -tokio = { version = "1", features = ["rt-multi-thread"] } - -[features] -default = [] -# default = ["async"] -async = [ - "tokio", - "futures-core", - "futures", - "tokio-util", - "wintun-bindings/async", -] - -[package.metadata.docs.rs] -features = ["async"] - [[example]] name = "read-async" required-features = ["async"] diff --git a/src/platform/linux/device.rs b/src/platform/linux/device.rs index 22ff9c97..a35ee1ab 100644 --- a/src/platform/linux/device.rs +++ b/src/platform/linux/device.rs @@ -117,7 +117,7 @@ impl Device { | if queues_num > 1 { iff_multi_queue } else { 0 }; let tun_fd = { - let fd = libc::open(b"/dev/net/tun\0".as_ptr() as *const _, O_RDWR); + let fd = libc::open(c"/dev/net/tun".as_ptr() as *const _, O_RDWR); let tun_fd = Fd::new(fd, true).map_err(|_| std::io::Error::last_os_error())?; if let Err(err) = tunsetiff(tun_fd.inner, &mut req as *mut _ as *mut _) {