Refactoring of frida_core and android_tun creation
modified: frida_client/src/client.rs new file: frida_core/src/android_tun.rs modified: frida_core/src/lib.rs deleted: frida_core/src/main.rs deleted: frida_core/src/tun.rs
This commit is contained in:
parent
8f4e84947c
commit
0690c0f781
@ -195,7 +195,7 @@ pub mod desktop {
|
|||||||
|
|
||||||
use crate::client::general::{CoreVpnClient, VpnClient};
|
use crate::client::general::{CoreVpnClient, VpnClient};
|
||||||
use frida_core::config::ClientConfiguration;
|
use frida_core::config::ClientConfiguration;
|
||||||
use frida_core::tun::create_tun;
|
use frida_core::create;
|
||||||
use frida_core::device::AbstractDevice;
|
use frida_core::device::AbstractDevice;
|
||||||
use log::info;
|
use log::info;
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
@ -320,7 +320,7 @@ pub mod desktop {
|
|||||||
let sock = UdpSocket::bind(("0.0.0.0", 0)).await.unwrap();
|
let sock = UdpSocket::bind(("0.0.0.0", 0)).await.unwrap();
|
||||||
sock.connect(&self.client_config.server.endpoint).await.unwrap();
|
sock.connect(&self.client_config.server.endpoint).await.unwrap();
|
||||||
|
|
||||||
let (dev_reader, dev_writer) = create_tun(config);
|
let (dev_reader, dev_writer) = create(config);
|
||||||
|
|
||||||
let mut client = CoreVpnClient{ client_config: self.client_config.clone(), close_token: tokio_util::sync::CancellationToken::new()};
|
let mut client = CoreVpnClient{ client_config: self.client_config.clone(), close_token: tokio_util::sync::CancellationToken::new()};
|
||||||
|
|
||||||
|
29
frida_core/src/android_tun.rs
Normal file
29
frida_core/src/android_tun.rs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
pub fn create(cfg: i32) -> (DeviceReader, DeviceWriter) {
|
||||||
|
// check this if android build won't work
|
||||||
|
let mut reader = unsafe { File::from_raw_fd(cfg) };
|
||||||
|
let mut writer = unsafe { File::from_raw_fd(cfg) };
|
||||||
|
|
||||||
|
(DeviceReader {reader}, DeviceWriter {writer})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DeviceWriter {
|
||||||
|
writer: File
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct DeviceReader {
|
||||||
|
reader: File
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceWriter {
|
||||||
|
pub async fn write(&mut self, buf: &Vec<u8>) -> Result<usize, Box<dyn Error>> {
|
||||||
|
Ok(self.writer.write(buf).await?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DeviceReader {
|
||||||
|
pub async fn read(&mut self, buf: &mut Vec<u8>) -> Result<usize, Box<dyn Error>> {
|
||||||
|
Ok(self.reader.read_buf(buf).await?)
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
pub mod device;
|
pub mod device;
|
||||||
pub mod tun;
|
|
||||||
pub mod obfs;
|
pub mod obfs;
|
||||||
pub mod udp;
|
pub mod udp;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
@ -21,3 +20,9 @@ mod mac_tun;
|
|||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub use r#mac_tun::*;
|
pub use r#mac_tun::*;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
mod android_tun;
|
||||||
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
pub use r#android_tun::*;
|
@ -1,35 +0,0 @@
|
|||||||
use env_logger::Builder;
|
|
||||||
use log::{info, error, LevelFilter};
|
|
||||||
|
|
||||||
mod device;
|
|
||||||
mod tun;
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
mod win_tun;
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
mod linux_tun;
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() {
|
|
||||||
Builder::new()
|
|
||||||
.filter(None, LevelFilter::Info)
|
|
||||||
.init();
|
|
||||||
|
|
||||||
let (reader, _writer) = tun::create_tun();
|
|
||||||
|
|
||||||
let a = tokio::spawn(async move {
|
|
||||||
let mut buf = Vec::new();
|
|
||||||
info!("Started!");
|
|
||||||
loop {
|
|
||||||
// info!("We've got {} bytes of data!", c)
|
|
||||||
let r = reader.read(&mut buf).await;
|
|
||||||
match r {
|
|
||||||
Ok(_c) => {},
|
|
||||||
Err(_e) => error!("We've got a nasty error message!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let _ = a.await;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
use crate::device::AbstractDevice;
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use crate::win_tun::{DeviceReader, DeviceWriter, create};
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
use crate::linux_tun::{DeviceReader, DeviceWriter, create};
|
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use crate::mac_tun::{DeviceReader, DeviceWriter, create};
|
|
||||||
|
|
||||||
pub fn create_tun(cfg: AbstractDevice) -> (DeviceReader, DeviceWriter) {
|
|
||||||
create(cfg)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user