diff --git a/src/client.rs b/src/client.rs index 8dda547..571d643 100644 --- a/src/client.rs +++ b/src/client.rs @@ -24,7 +24,7 @@ use network_interface::NetworkInterfaceConfig; use robusta_jni::jni::JNIEnv; use crate::jni::FridaLib; -pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIEnv<'_>, close_token: CancellationToken) { +pub async fn client_mode(client_config: ClientConfiguration, fd: i32, /*env: &JNIEnv<'_>,*/ close_token: CancellationToken) { let (ltx, mut lrx) = mpsc::unbounded_channel::>(); ltx.send("Starting client...".as_bytes().to_vec()); @@ -138,7 +138,8 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE } rr1 = lrx.recv() => { if let Some(bytes) = rr1 { - FridaLib::traceFromNative(&env, String::from_utf8_lossy(&bytes).to_string()); + crate::log2java(String::from_utf8_lossy(&bytes).to_string()); + //FridaLib::traceFromNative(&env, ); } } rr2 = mx.recv() => { diff --git a/src/main.rs b/src/main.rs index d163fed..8ce86c6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,13 @@ mod udp; mod mobile; static TUN_QUIT: std::sync::Mutex> = std::sync::Mutex::new(None); +static LOG_ENV: Option<&JNIEnv> = None; + +pub fn log2java(text: String) { + if Some(env) = LOG_ENV { + jni::FridaLib::traceFromNative(env, text); + } +} #[bridge] mod jni { @@ -60,17 +67,19 @@ mod jni { return Ok(-2); } + LOG_ENV = Some(env); + let main_loop = async move { /*if let Err(err) = { FridaLib::traceFromNative(env, format!("main loop error: {}", err)); return Err(err); }*/ - mobile::mobile_run(config_b32, close_fd_on_drop, tun_fd, env, close_token).await; + mobile::mobile_run(config_b32, close_fd_on_drop, tun_fd, /*env,*/ close_token).await; }; let exit_code = match tokio::runtime::Builder::new_multi_thread().enable_all().build() { Err(_e) => -3, - Ok(rt) => { rt.block_on(main_loop); -4 } + Ok(rt) => { rt.spawn(main_loop); -4 } //block_on }; Ok(exit_code) diff --git a/src/mobile.rs b/src/mobile.rs index ae7032e..a1f0934 100644 --- a/src/mobile.rs +++ b/src/mobile.rs @@ -5,7 +5,7 @@ use jni::sys::jint; use tokio::runtime::Runtime; use robusta_jni::jni::JNIEnv; -pub async fn mobile_run(cfg_raw: String, close_fd_on_drop: bool, tun_fd: i32, env: &JNIEnv<'_>, close_token: tokio_util::sync::CancellationToken) { +pub async fn mobile_run(cfg_raw: String, close_fd_on_drop: bool, tun_fd: i32, /*env: &JNIEnv<'_>,*/ close_token: tokio_util::sync::CancellationToken) { let config: ClientConfiguration = serde_yaml::from_slice(hex::decode(cfg_raw).unwrap().as_slice()).expect("Bad client config file structure"); - client::client_mode(config, tun_fd, env, close_token).await; + client::client_mode(config, tun_fd, /*env,*/ close_token).await; } \ No newline at end of file