Implementing linux tun adapter
Some checks failed
gitea/Frida/pipeline/head There was a failure building this commit

new file:   frida_core/src/linux_tun.rs
	modified:   frida_core/src/main.rs
	modified:   frida_core/src/win_tun.rs
This commit is contained in:
Michael Wain 2024-12-08 04:02:17 +03:00
parent 0edc0fef1d
commit 32eec5252a
3 changed files with 44 additions and 3 deletions

View File

@ -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 <tun-name> 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<u8>) -> Result<usize, Box<dyn Error>> {
}
}
impl DeviceReader {
pub async fn read(&self, buf: &mut Vec<u8>) -> Result<usize, Box<dyn Error>> {
}
}

View File

@ -3,8 +3,13 @@ use log::{info, error, LevelFilter};
mod device; mod device;
mod tun; mod tun;
#[cfg(target_os = "windows")]
mod win_tun; mod win_tun;
#[cfg(target_os = "linux")]
mod linux_tun;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
Builder::new() Builder::new()