feat: tun2 has been merged back to tun (meh/rust-tun)

This commit is contained in:
zonyitoo
2024-12-04 00:17:32 +08:00
parent f21869a832
commit 3f62aabd2a
4 changed files with 28 additions and 26 deletions

12
Cargo.lock generated
View File

@@ -1880,7 +1880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
"windows-targets 0.48.5",
"windows-targets 0.52.6",
]
[[package]]
@@ -3298,7 +3298,7 @@ dependencies = [
"tokio-native-tls",
"tokio-rustls",
"trait-variant",
"tun2",
"tun",
"webpki-roots",
"windows-sys 0.59.0",
"zstd",
@@ -3873,10 +3873,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "tun2"
version = "4.0.0"
name = "tun"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21afe73d3d42581a7400fbf5aec057a646ffe3f8bb5ae3f61d88c7e7f4ac77be"
checksum = "f3c3f82bccbec181c56278683da7d915cf875a6cf8a450b3bcf1367de222775e"
dependencies = [
"bytes",
"cfg-if",
@@ -3886,7 +3886,7 @@ dependencies = [
"libc",
"log",
"nix",
"thiserror 1.0.69",
"thiserror 2.0.3",
"tokio",
"tokio-util",
"windows-sys 0.59.0",

View File

@@ -96,7 +96,7 @@ local-tunnel = ["local"]
# Enable socks4 protocol for sslocal
local-socks4 = ["local"]
# Enable Tun interface protocol for sslocal
local-tun = ["local", "etherparse", "tun2", "smoltcp"]
local-tun = ["local", "etherparse", "tun", "smoltcp"]
# Enable Fake DNS
local-fake-dns = ["local", "trust-dns", "sled", "bson"]
# sslocal support online URL (SIP008 Online Configuration Delivery)
@@ -195,9 +195,7 @@ flate2 = { version = "1.0", optional = true }
brotli = { version = "7.0", optional = true }
zstd = { version = "0.13", optional = true }
tun2 = { version = "4.0", optional = true, default-features = false, features = [
"async",
] }
tun = { version = "0.7", optional = true, features = ["async"] }
etherparse = { version = "0.16", optional = true }
smoltcp = { version = "0.12", optional = true, default-features = false, features = [
"std",

View File

@@ -9,7 +9,7 @@ use std::{
};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tun2::{AbstractDevice, Configuration, Error as TunError};
use tun::{AbstractDevice, Configuration, Error as TunError};
pub struct FakeQueue;
@@ -32,55 +32,59 @@ impl Write for FakeQueue {
pub struct FakeDevice;
impl AbstractDevice for FakeDevice {
fn tun_name(&self) -> tun2::Result<String> {
fn tun_name(&self) -> tun::Result<String> {
Err(TunError::NotImplemented)
}
fn set_tun_name(&mut self, _: &str) -> tun2::Result<()> {
fn tun_index(&self) -> tun::Result<i32> {
Err(TunError::NotImplemented)
}
fn enabled(&mut self, _: bool) -> tun2::Result<()> {
fn set_tun_name(&mut self, _: &str) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn address(&self) -> tun2::Result<IpAddr> {
fn enabled(&mut self, _: bool) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn set_address(&mut self, _: IpAddr) -> tun2::Result<()> {
fn address(&self) -> tun::Result<IpAddr> {
Err(TunError::NotImplemented)
}
fn destination(&self) -> tun2::Result<IpAddr> {
fn set_address(&mut self, _: IpAddr) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn set_destination(&mut self, _: IpAddr) -> tun2::Result<()> {
fn destination(&self) -> tun::Result<IpAddr> {
Err(TunError::NotImplemented)
}
fn broadcast(&self) -> tun2::Result<IpAddr> {
fn set_destination(&mut self, _: IpAddr) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn set_broadcast(&mut self, _: IpAddr) -> tun2::Result<()> {
fn broadcast(&self) -> tun::Result<IpAddr> {
Err(TunError::NotImplemented)
}
fn netmask(&self) -> tun2::Result<IpAddr> {
fn set_broadcast(&mut self, _: IpAddr) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn set_netmask(&mut self, _: IpAddr) -> tun2::Result<()> {
fn netmask(&self) -> tun::Result<IpAddr> {
Err(TunError::NotImplemented)
}
fn mtu(&self) -> tun2::Result<u16> {
fn set_netmask(&mut self, _: IpAddr) -> tun::Result<()> {
Err(TunError::NotImplemented)
}
fn set_mtu(&mut self, _: u16) -> tun2::Result<()> {
fn mtu(&self) -> tun::Result<u16> {
Err(TunError::NotImplemented)
}
fn set_mtu(&mut self, _: u16) -> tun::Result<()> {
Err(TunError::NotImplemented)
}

View File

@@ -28,11 +28,11 @@ cfg_if! {
target_os = "android",
target_os = "windows",
target_os = "freebsd"))] {
use tun2::{
use tun::{
create_as_async, AsyncDevice, Configuration as TunConfiguration, AbstractDevice, Error as TunError, Layer,
};
} else {
use tun2::{AbstractDevice, Configuration as TunConfiguration, Error as TunError, Layer};
use tun::{AbstractDevice, Configuration as TunConfiguration, Error as TunError, Layer};
mod fake_tun;
use self::fake_tun::{create_as_async, AsyncDevice};