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:31:58 +03:00
parent 118c550c2b
commit d17fd336bc

View File

@ -28,12 +28,11 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
let sock = UdpSocket::bind("0.0.0.0:25565").await.unwrap();
sock.connect(&client_config.server.endpoint).await.unwrap();
//let mut config = tun2::Configuration::default();
info!("FD: {:?}", &fd);
//config.raw_fd(fd).up();
//let mut dev = tun2::create_as_async(&config).unwrap();
//let (mut dev_reader, mut dev_writer) = dev.split();
let mut dev = unsafe { File::from_raw_fd(fd) };
let mut dev_reader = BufReader::new(dev);
let mut dev_writer = BufWriter::new(dev);
let sock_rec = Arc::new(sock);
let sock_snd = sock_rec.clone();
@ -43,7 +42,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
let cipher_shared: Arc<Mutex<Option<x25519_dalek::SharedSecret>>> = Arc::new(Mutex::new(None));
/* tokio::spawn(async move {
tokio::spawn(async move {
while let Ok(bytes) = rx.recv() {
info!("Write to tun.");
dev_writer.write_all(&bytes).unwrap();
@ -51,7 +50,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
});
tokio::spawn(async move {
let mut buf = vec![0; 8192];
let mut buf = vec![0; 1400]; // mtu
while let Ok(n) = dev_reader.read(&mut buf) {
info!("Read from tun.");
dx.send(buf[..n].to_vec()).unwrap();
@ -139,14 +138,7 @@ pub async fn client_mode(client_config: ClientConfiguration, fd: i32) -> i32 {
warn!("There is no shared_secret in main loop");
}
}
}*/
let mut f = unsafe { File::from_raw_fd(fd) };
let mut buf = vec![0; 1400];
while let Ok(n) = f.read(&mut buf) {
info!("Read from tun. {:?} bytes", n);
return n as i32;
}
info!("end.");
-2
}