modified: src/client.rs
All checks were successful
gitea/Frida-android-native/pipeline/head This commit looks good
All checks were successful
gitea/Frida-android-native/pipeline/head This commit looks good
This commit is contained in:
parent
5514074861
commit
9b417a1686
@ -46,17 +46,19 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
||||
|
||||
let cipher_shared: Arc<Mutex<Option<x25519_dalek::SharedSecret>>> = Arc::new(Mutex::new(None));
|
||||
|
||||
let lltx = ltx.clone();
|
||||
tokio::spawn(async move {
|
||||
while let Ok(bytes) = rx.recv() {
|
||||
ltx.send("Write to tun.".as_bytes().to_vec());
|
||||
lltx.send("Write to tun.".as_bytes().to_vec());
|
||||
dev_writer.write_all(&bytes).unwrap();
|
||||
}
|
||||
});
|
||||
|
||||
let llltx = ltx.clone();
|
||||
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().to_vec());
|
||||
llltx.send("Read from tun.".as_bytes().to_vec());
|
||||
dx.send(buf[..n].to_vec()).unwrap();
|
||||
}
|
||||
});
|
||||
@ -64,12 +66,13 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32, env: &JNIE
|
||||
let priv_key = BASE64_STANDARD.decode(client_config.client.private_key).unwrap();
|
||||
|
||||
let cipher_shared_clone = cipher_shared.clone();
|
||||
let sr_ltx = ltx.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut buf = vec![0; 4096];
|
||||
|
||||
loop {
|
||||
if let Ok(l) = sock_rec.recv(&mut buf).await {
|
||||
ltx.send("Read from socket".as_bytes().to_vec());
|
||||
sr_ltx.send("Read from socket".as_bytes().to_vec());
|
||||
let mut s_cipher = cipher_shared_clone.lock().await;
|
||||
match buf.first() {
|
||||
Some(h) => {
|
||||
@ -94,17 +97,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).as_bytes().to_vec()); }
|
||||
Err(error) => { sr_ltx.send(format!("Decryption error! {:?}", error).as_bytes().to_vec()); }
|
||||
}
|
||||
} else {
|
||||
ltx.send("There is no static_secret".as_bytes().to_vec());
|
||||
sr_ltx.send("There is no static_secret".as_bytes().to_vec());
|
||||
}
|
||||
}, // payload
|
||||
2 => { ltx.send("Got keepalive packet".as_bytes().to_vec()); },
|
||||
_ => { ltx.send("Unexpected header value.".as_bytes().to_vec()); }
|
||||
2 => { sr_ltx.send("Got keepalive packet".as_bytes().to_vec()); },
|
||||
_ => { sr_ltx.send("Unexpected header value.".as_bytes().to_vec()); }
|
||||
}
|
||||
},
|
||||
None => { ltx.send("There is no header.".as_bytes().to_vec()); }
|
||||
None => { sr_ltx.send("There is no header.".as_bytes().to_vec()); }
|
||||
}
|
||||
drop(s_cipher);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user