diff --git a/frida_core/src/linux_tun.rs b/frida_core/src/linux_tun.rs new file mode 100644 index 0000000..060b6f3 --- /dev/null +++ b/frida_core/src/linux_tun.rs @@ -0,0 +1,36 @@ +use std::sync::Arc; +use std::error::Error; + +pub fn create() -> (DeviceReader, DeviceWriter) { + let tun = Arc::new( + Tun::builder() + .name("") // if name is empty, then it is set by kernel. + .tap() // uses TAP instead of TUN (default). + .packet_info() // avoids setting IFF_NO_PI. + .up() // or set it up manually using `sudo ip link set up`. + .try_build() // or `.try_build_mq(queues)` for multi-queue support. + .unwrap(), + ); + + println!("tun created, name: {}, fd: {}", tun.name(), tun.as_raw_fd()); + + let (mut reader, mut _writer) = tokio::io::split(tun); +} + +pub struct DeviceWriter { + +} + +pub struct DeviceReader { + +} + +impl DeviceWriter { + pub async fn write(&self, buf: &Vec) -> Result> { + } +} + +impl DeviceReader { + pub async fn read(&self, buf: &mut Vec) -> Result> { + } +} \ No newline at end of file diff --git a/frida_core/src/main.rs b/frida_core/src/main.rs index 54dfa69..733bfdc 100644 --- a/frida_core/src/main.rs +++ b/frida_core/src/main.rs @@ -3,8 +3,13 @@ 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() diff --git a/frida_core/src/win_tun.rs b/frida_core/src/win_tun.rs index 224286a..e395c20 100644 --- a/frida_core/src/win_tun.rs +++ b/frida_core/src/win_tun.rs @@ -12,9 +12,9 @@ pub fn create() -> (DeviceReader, DeviceWriter) { let adapter = match wintun::Adapter::open(&wintun, "Demo") { Ok(a) => a, Err(_) => { - wintun::Adapter::create(&wintun, "Demo", "Example", None) - .expect("Failed to create wintun adapter!") - } + wintun::Adapter::create(&wintun, "Demo", "Example", None) + .expect("Failed to create wintun adapter!") + } }; let session = Arc::new(adapter.start_session(wintun::MAX_RING_CAPACITY).unwrap());