Skip to content
Merged
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
87 changes: 48 additions & 39 deletions mobile/Cargo.lock

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

3 changes: 3 additions & 0 deletions mobile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ once_cell = "1.21.1"
serde_json = "1.0"

[target.'cfg(target_os = "android")'.dependencies]
# Android consumers (VpnService.Builder hands in a pre-configured fd) use the
# fd-handoff TUN path. This feature enables that path in mycelium.
mycelium = { path = "../mycelium", features = ["vendored-openssl", "androidtunfd"] }
tracing-android = "0.2.0"

[target.'cfg(target_os = "ios")'.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion mycelium-tun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
license-file = "../LICENSE"

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
tokio = { version = "1.52.3", default-features = false, features = ["net"] }
nix = { version = "0.31.3", features = ["ioctl", "net"] }
libc = "0.2"
Expand Down
12 changes: 7 additions & 5 deletions mycelium-tun/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//! Platform-specific TUN device implementations.
//!
//! Currently only Linux is supported. On other platforms this crate is empty.
//! Linux and Android share the same implementation (Android is Linux + bionic
//! and exposes the same `/dev/net/tun` uAPI). On other platforms this crate
//! is empty.

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
mod checksum;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
mod offload;

#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use linux::{ReadHalf, Tun, WriteHalf};
7 changes: 7 additions & 0 deletions mycelium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ vendored-openssl = ["openssl/vendored"]
mactunfd = [
"tun/appstore",
] #mactunfd is a flag to specify that macos should provide tun FD instead of tun name
# androidtunfd is the Android equivalent of mactunfd: when enabled the caller
# (typically an app using Android's VpnService) provides a pre-configured TUN
# file descriptor. Default Android builds (e.g. a `cargo ndk` system-service
# build) open and manage the TUN device themselves via the shared Linux path.
androidtunfd = []
# Build a C ABI surface (cdylib + staticlib + generated header) on top of the
# core node. Used by external daemons that wrap libmycelium without depending
# on Rust as a build dependency.
Expand Down Expand Up @@ -97,6 +102,8 @@ wintun = "0.5.1"
[target.'cfg(target_os = "android")'.dependencies]
tun = { git = "https://github.com/LeeSmet/rust-tun", features = ["async"] }
libc = "0.2.186"
nix = { version = "0.31.3", features = ["socket"] }
mycelium-tun = { path = "../mycelium-tun" }

[target.'cfg(target_os = "ios")'.dependencies]
tun = { git = "https://github.com/LeeSmet/rust-tun", features = ["async"] }
Expand Down
Loading
Loading