From 1f729e3506fd6802b91d28d97fe2b71c2df7b4f5 Mon Sep 17 00:00:00 2001 From: alterdekim Date: Mon, 7 Oct 2024 22:23:12 +0300 Subject: [PATCH] modified: src/client.rs --- src/client.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/client.rs b/src/client.rs index 8049c38..85299f3 100644 --- a/src/client.rs +++ b/src/client.rs @@ -26,13 +26,13 @@ use crate::jni::FridaLib; pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIEnv<'_>) { let (ltx, lrx) = unbounded::>(); - ltx.send("Starting client...".as_bytes()); + ltx.send("Starting client...".to_vec()); let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap(); sock.connect(&client_config.server.endpoint).await.unwrap(); - ltx.send(format!("FD: {:?}", &fd).as_bytes()); - ltx.send("So exhausting".as_bytes()); + ltx.send(format!("FD: {:?}", &fd).to_vec()); + ltx.send("So exhausting".to_vec()); let mut dev = unsafe { File::from_raw_fd(fd) }; let mut dev1 = dev.try_clone().unwrap(); let mut dev_reader = BufReader::new(dev); @@ -54,7 +54,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE tokio::spawn(async move { while let Ok(bytes) = rx.recv() { - ltx.send("Write to tun.".as_bytes()); + ltx.send("Write to tun.".to_vec()); dev_writer.write_all(&bytes).unwrap(); } }); @@ -62,7 +62,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE tokio::spawn(async move { let mut buf = vec![0; 1400]; // mtu while let Ok(n) = dev_reader.read(&mut buf) { - ltx.send("Read from tun.".as_bytes()); + ltx.send("Read from tun.".to_vec()); dx.send(buf[..n].to_vec()).unwrap(); } }); @@ -75,7 +75,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE loop { if let Ok(l) = sock_rec.recv(&mut buf).await { - ltx.send("Read from socket".as_bytes()); + ltx.send("Read from socket".to_vec()); let mut s_cipher = cipher_shared_clone.lock().await; match buf.first() { Some(h) => { @@ -100,17 +100,17 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE let nonce = Nonce::clone_from_slice(&wrapped_packet.nonce); match aes.decrypt(&nonce, &wrapped_packet.data[..]) { Ok(decrypted) => { let _ = tx.send(decrypted); }, - Err(error) => { ltx.send(format!("Decryption error! {:?}", error)); } + Err(error) => { ltx.send(format!("Decryption error! {:?}", error).to_vec()); } } } else { - ltx.send("There is no static_secret".as_bytes()); + ltx.send("There is no static_secret".to_vec()); } }, // payload - 2 => { ltx.send("Got keepalive packet".as_bytes()); }, - _ => { ltx.send("Unexpected header value.".as_bytes()); } + 2 => { ltx.send("Got keepalive packet".to_vec()); }, + _ => { ltx.send("Unexpected header value.".to_vec()); } } }, - None => { ltx.send("There is no header.".as_bytes()); } + None => { ltx.send("There is no header.".to_vec()); } } drop(s_cipher); } @@ -139,13 +139,13 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE if let Ok(ciphered_d) = ciphered_data { let vpn_packet = UDPVpnPacket{ data: ciphered_d, nonce: nonce.to_vec()}; let serialized_data = vpn_packet.serialize(); - ltx.send("Write to socket".as_bytes()); + ltx.send("Write to socket".to_vec()); sock_snd.send(&serialized_data).await.unwrap(); } else { - ltx.send("Socket encryption failed.".as_bytes()); + ltx.send("Socket encryption failed.".to_vec()); } } else { - ltx.send("There is no shared_secret in main loop".as_bytes()); + ltx.send("There is no shared_secret in main loop".to_vec()); } } }