modified: src/client.rs
Some checks failed
gitea/Frida-android-native/pipeline/head There was a failure building this commit

This commit is contained in:
Michael Wain 2024-10-05 20:04:44 +03:00
parent 686e82a3ec
commit 5b5f621cac

View File

@ -1,13 +1,18 @@
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use socket2::SockAddr; use socket2::SockAddr;
use tokio::{net::UdpSocket, sync::Mutex}; use tokio::{net::UdpSocket, sync::Mutex};
use std::{io::{Read, Write}, net::SocketAddr};
use base64::prelude::*; use base64::prelude::*;
use log::{error, info, warn}; use log::{error, info, warn};
use std::sync::Arc; use std::sync::Arc;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use x25519_dalek::{PublicKey, StaticSecret}; use x25519_dalek::{PublicKey, StaticSecret};
use std::process::Command; use std::{
fs::File,
io::{self, Read, Write},
net::SocketAddr,
process::Command,
os::unix::io::FromRawFd,
};
use aes_gcm::{ use aes_gcm::{
aead::{Aead, AeadCore, KeyInit, OsRng}, aead::{Aead, AeadCore, KeyInit, OsRng},
Aes256Gcm, Nonce}; Aes256Gcm, Nonce};
@ -23,11 +28,11 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap(); let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
sock.connect(&client_config.server.endpoint).await.unwrap(); sock.connect(&client_config.server.endpoint).await.unwrap();
let mut config = tun2::Configuration::default(); //let mut config = tun2::Configuration::default();
info!("FD: {:?}", &fd); info!("FD: {:?}", &fd);
config.raw_fd(fd).up(); //config.raw_fd(fd).up();
let mut dev = tun2::create_as_async(&config).unwrap(); //let mut dev = tun2::create_as_async(&config).unwrap();
//let (mut dev_reader, mut dev_writer) = dev.split(); //let (mut dev_reader, mut dev_writer) = dev.split();
let sock_rec = Arc::new(sock); let sock_rec = Arc::new(sock);
@ -135,9 +140,12 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
} }
} }
}*/ }*/
let mut buf = vec![0; 2048]; let mut f = unsafe { File::from_raw_fd(&fd) };
while let Ok(n) = dev.read(&mut buf) {
let mut buf = vec![0; 1400];
while let Ok(n) = f.read(&mut buf) {
info!("Read from tun. {:?} bytes", n); info!("Read from tun. {:?} bytes", n);
return n.into();
} }
info!("end."); info!("end.");
-2 -2