blob: 5caaa863dfbdecc0b739d28694484e4e499b2854 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Here we iniitialize systems crucial for nsc
use std::io::Read;
use crate::sniffing::headers::sniff_raw_packets;
pub fn init() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
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)?;
// dbg!(sniff_raw_packets(&buf[0..amount])?);
let govno = sniff_raw_packets(&buf[0..amount])?;
println!("{govno:?}")
// dbg!("{:?}", &buf[0..amount]);
}
}
|