From 2818a34862b5dffaef43c8b5cf763f90f17bf93c Mon Sep 17 00:00:00 2001 From: alterdekim Date: Sat, 12 Oct 2024 16:39:52 +0300 Subject: [PATCH] Changes to be committed: modified: src/client.rs modified: src/main.rs modified: src/mobile.rs --- src/client.rs | 10 ++++------ src/main.rs | 4 ++-- src/mobile.rs | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/client.rs b/src/client.rs index 0e4fff3..471f0c8 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, lrx) = unbounded::>(); ltx.send("Starting client...".as_bytes().to_vec()); @@ -120,10 +120,8 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, /*env: &JN let s_cipher = cipher_shared.clone(); loop { if close_token.is_cancelled() { - //sock_read_task.abort(); - //dev_read_task.abort(); - //return; - ltx.send("Closed token called".as_bytes().to_vec()); + sock_read_task.abort(); + dev_read_task.abort(); return; } if let Ok(bytes) = rx.try_recv() { @@ -136,7 +134,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, /*env: &JN } } if let Ok(bytes) = lrx.try_recv() { - //FridaLib::traceFromNative(&env, String::from_utf8_lossy(&bytes).to_string()); + FridaLib::traceFromNative(&env, String::from_utf8_lossy(&bytes).to_string()); } if let Ok(bytes) = mx.try_recv() { let s_c = s_cipher.lock().await; diff --git a/src/main.rs b/src/main.rs index 835a4d4..d163fed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,12 +65,12 @@ mod jni { 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.spawn(main_loop); -4 } // block_on + Ok(rt) => { rt.block_on(main_loop); -4 } }; Ok(exit_code) diff --git a/src/mobile.rs b/src/mobile.rs index 47ef6f0..ae7032e 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