From 06d4e558cdf97b64e4cbc95becf1b25c1c24950e Mon Sep 17 00:00:00 2001 From: zedddie Date: Sun, 15 Mar 2026 14:59:11 +0100 Subject: sniffing early work use `tun` crate examope for starters, to map all traffic through tun virtual interface, in next commits will push these packets to sniffing module which will deciede further modifications of proxies based by user's Config. --- src/startup.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/startup.rs (limited to 'src/startup.rs') diff --git a/src/startup.rs b/src/startup.rs new file mode 100644 index 0000000..32ed278 --- /dev/null +++ b/src/startup.rs @@ -0,0 +1,25 @@ +// Here we iniitialize systems crucial for nsc +use std::io::Read; + +pub fn init() -> Result<(), Box> { + let mut config = tun::Configuration::default(); + config + .address((10, 0, 0, 9)) + .netmask((255, 255, 255, 0)) + .destination((10, 0, 0, 1)) + .up(); + + #[cfg(target_os = "linux")] + config.platform_config(|config| { + // requiring root privilege to acquire complete functions + config.ensure_root_privileges(true); + }); + + let mut dev = tun::create(&config)?; + let mut buf = [0; 4096]; + + loop { + let amount = dev.read(&mut buf)?; + println!("{:?}", &buf[0..amount]); + } +} -- cgit v1.2.3