Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tun): use libtun #456

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 83 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions clash_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ axum = { version = "0.7", features = ["ws"] }
tower-http = { version = "0.5.2", features = ["fs", "trace", "cors"] }
chrono = { version = "0.4.38", features = ["serde"] }

tun = { git = "https://github.com/Watfaq/rust-tun.git", rev = "8f7568190f1200d3e272ca534baf8d1578147e18", features = ["async"] }
netstack-lwip = { git = "https://github.com/Watfaq/netstack-lwip.git", rev = "2817bf82740e04bbee6b7bf1165f55657a6ed163" }

boringtun = { version = "0.6.0", git = "https://github.com/cloudflare/boringtun.git", rev = "f672bb6c1e1e371240a8d151f15854687eb740bb" }
smoltcp = { version = "0.11", default-features = false, features = ["std", "log", "medium-ip", "proto-ipv4", "proto-ipv6", "socket-udp", "socket-tcp"] }

Expand Down Expand Up @@ -121,6 +118,9 @@ console-subscriber = { version = "0.2.0" }
tracing-timing = { version = "0.6.0" }
criterion = { version = "0.5", features = ["html_reports", "async_tokio"], optional = true }

# libtun = { path = "/home/itsusinn/Workspace/Code/libtun" }
libtun = { rev = "e8db488", git = "https://github.com/Itsusinn/libtun.git" }

[dev-dependencies]
tempfile = "3.10"
ctor = "0.2"
Expand Down
7 changes: 1 addition & 6 deletions clash_lib/src/proxy/tun/datagram.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{net::SocketAddr, task::Poll};
use std::task::Poll;

use futures::{ready, Sink, Stream};

Expand All @@ -14,8 +14,6 @@ pub struct TunDatagram {

pkt: Option<UdpPacket>,
flushed: bool,
#[allow(unused)]
local_addr: SocketAddr,
}

impl TunDatagram {
Expand All @@ -24,15 +22,12 @@ impl TunDatagram {
tx: tokio::sync::mpsc::Sender<UdpPacket>,
// receive from tun
rx: tokio::sync::mpsc::Receiver<UdpPacket>,
// the address of the tun udp socket
local_addr: SocketAddr,
) -> Self {
Self {
rx,
tx,
pkt: None,
flushed: true,
local_addr,
}
}
}
Expand Down
Loading
Loading