@@ -84,7 +84,8 @@ pub struct Config<M> {
8484 #[ cfg( any(
8585 target_os = "linux" ,
8686 all( target_os = "macos" , not( feature = "mactunfd" ) ) ,
87- target_os = "windows"
87+ target_os = "windows" ,
88+ all( target_os = "android" , not( feature = "androidtunfd" ) ) ,
8889 ) ) ]
8990 pub tun_name : String ,
9091
@@ -97,14 +98,16 @@ pub struct Config<M> {
9798 /// Mark that's set on all packets that we send on the underlying network
9899 pub firewall_mark : Option < u32 > ,
99100
100- // tun_fd is android, iOS, macos on appstore specific option
101- // We can't create TUN device from the Rust code in android, iOS, and macos on appstore.
102- // So, we create the TUN device on Kotlin(android) or Swift(iOS, macos) then pass
103- // the TUN's file descriptor to mycelium.
101+ // tun_fd is the iOS / macos-appstore / android-VpnService option.
102+ // We can't create the TUN device from Rust on iOS or macOS-appstore (the
103+ // platform doesn't expose `/dev/net/tun` to the app). Android apps using
104+ // `VpnService.Builder` are in the same situation — the framework hands
105+ // back a ready fd. In these cases the TUN is created by Kotlin (android)
106+ // or Swift (iOS, macOS) and the file descriptor is passed to mycelium.
104107 #[ cfg( any(
105- target_os = "android" ,
106108 target_os = "ios" ,
107109 all( target_os = "macos" , feature = "mactunfd" ) ,
110+ all( target_os = "android" , feature = "androidtunfd" ) ,
108111 ) ) ]
109112 pub tun_fd : Option < i32 > ,
110113
@@ -281,7 +284,8 @@ where
281284 #[ cfg( any(
282285 target_os = "linux" ,
283286 all( target_os = "macos" , not( feature = "mactunfd" ) ) ,
284- target_os = "windows"
287+ target_os = "windows" ,
288+ all( target_os = "android" , not( feature = "androidtunfd" ) ) ,
285289 ) ) ]
286290 let tun_config = TunConfig {
287291 name : config. tun_name . clone ( ) ,
@@ -291,9 +295,9 @@ where
291295 . expect ( "Static configured TUN route is valid; qed" ) ,
292296 } ;
293297 #[ cfg( any(
294- target_os = "android" ,
295298 target_os = "ios" ,
296299 all( target_os = "macos" , feature = "mactunfd" ) ,
300+ all( target_os = "android" , feature = "androidtunfd" ) ,
297301 ) ) ]
298302 let tun_config = TunConfig {
299303 tun_fd : config. tun_fd . unwrap ( ) ,
0 commit comments