From 946af19d5b192baac884f700407f94083f9b5915 Mon Sep 17 00:00:00 2001 From: alterdekim Date: Tue, 8 Oct 2024 18:56:26 +0300 Subject: [PATCH] modified: src/client.rs --- src/client.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/client.rs b/src/client.rs index 911a4ec..ec858d5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -45,21 +45,6 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE let cipher_shared: Arc>> = Arc::new(Mutex::new(None)); - let lltx = ltx.clone(); - tokio::spawn(async move { - loop { - if let Ok(bytes) = rx.recv() { - lltx.send("Write to tun.".as_bytes().to_vec()); - if let Err(e) = dev_writer.write_all(&bytes).await { - lltx.send(format!("Writing error: {:?}", e).as_bytes().to_vec()); - } - if let Err(e) = dev_writer.flush().await { - lltx.send(format!("Flushing error: {:?}", e).as_bytes().to_vec()); - } - } - } - }); - let llltx = ltx.clone(); tokio::spawn(async move { let mut buf = vec![0; 1400]; // mtu @@ -133,6 +118,15 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE let s_cipher = cipher_shared.clone(); loop { + if let Ok(bytes) = rx.try_recv() { + ltx.send("Write to tun.".as_bytes().to_vec()); + if let Err(e) = dev_writer.write_all(&bytes).await { + ltx.send(format!("Writing error: {:?}", e).as_bytes().to_vec()); + } + if let Err(e) = dev_writer.flush().await { + ltx.send(format!("Flushing error: {:?}", e).as_bytes().to_vec()); + } + } if let Ok(bytes) = lrx.try_recv() { FridaLib::traceFromNative(&env, String::from_utf8_lossy(&bytes).to_string()); }