Skip to content

Commit

Permalink
Decouple internal Android tun details from wireguard monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Aug 9, 2024
1 parent 72e1e47 commit c14bc32
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ open class TalpidVpnService : LifecycleVpnService() {
private val tunIsOpen
get() = activeTunStatus?.isOpen ?: false

private var currentTunConfig = defaultTunConfig()
private var currentTunConfig: TunConfig? = null
private var attemptsWithSameTun = 0

// Used by JNI
Expand Down Expand Up @@ -156,8 +156,6 @@ open class TalpidVpnService : LifecycleVpnService() {
}
}

private external fun defaultTunConfig(): TunConfig

private external fun waitForTunnelUp(tunFd: Int, isIpv6Enabled: Boolean)

companion object {
Expand Down
23 changes: 4 additions & 19 deletions mullvad-jni/src/talpid_vpn_service.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use ipnetwork::IpNetwork;
use jnix::{
jni::{
objects::JObject,
sys::{jboolean, jint, JNI_FALSE},
JNIEnv,
},
IntoJava, JnixEnv,
use jnix::jni::{
objects::JObject,
sys::{jboolean, jint, JNI_FALSE},
JNIEnv,
};
use nix::sys::{
select::{pselect, FdSet},
Expand All @@ -18,7 +15,6 @@ use std::{
os::unix::io::RawFd,
time::{Duration, Instant},
};
use talpid_tunnel::tun_provider::TunConfig;
use talpid_types::ErrorExt;

#[derive(Debug, thiserror::Error)]
Expand All @@ -33,17 +29,6 @@ enum Error {
TunnelDeviceTimeout,
}

#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_net_mullvad_talpid_TalpidVpnService_defaultTunConfig<'env>(
env: JNIEnv<'env>,
_this: JObject<'_>,
) -> JObject<'env> {
let env = JnixEnv::from(env);

TunConfig::default().into_java(&env).forget()
}

#[no_mangle]
#[allow(non_snake_case)]
pub extern "system" fn Java_net_mullvad_talpid_TalpidVpnService_waitForTunnelUp(
Expand Down
Loading

0 comments on commit c14bc32

Please sign in to comment.