From cc95fb8a0fb3b7bc2b35d05180ef1870497213b2 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sun, 18 May 2025 14:50:36 -0500 Subject: fix adding udp stats to tcp vec --- .gitignore | 3 +++ README.md | 23 +++++++++++++++++++++++ skim-cli/src/main.rs | 2 +- skim/src/main.rs | 4 ++-- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index ea8c4bf..af3cdc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /target + +# https://github.com/fasterthanlime/free-of-syn/blob/main/absolve.sh +absolve.sh \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac2cafa --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +[![free of syn](https://img.shields.io/badge/free%20of-syn-hotpink)](https://github.com/fasterthanlime/free-of-syn) + +**skim** +skim records the sizes of packets passing through an interface so you +can monitor network usage. it sorts this information by transport type, +tcp/udp, and port number. + +skim exposes an interface for retrieving statistics on tcp port 6666. +first send a u32, big endian, and then json data with the ports you +want. the json should look like this: +`{ "tcp": [80, 443], "udp": [53] }` + +you'll get a response back in a similar format. the first four bytes +will be the length of the response, big endian, and then the json data. +the data'll look like this: +```json +{ + "tcp":[{"port":80,"tx":0,"rx":0},{"port":443,"tx":56260,"rx":4195}], + "udp":[{"port":53,"tx":210,"rx":173}] +} +``` + +skim records network traffic assuming the host system is acting as a server. \ No newline at end of file diff --git a/skim-cli/src/main.rs b/skim-cli/src/main.rs index 880b99f..af2bbd5 100644 --- a/skim-cli/src/main.rs +++ b/skim-cli/src/main.rs @@ -6,7 +6,7 @@ use std::{ fn main() { let mut tcp = TcpStream::connect("127.0.0.1:6666").unwrap(); - let query = r#"{"tcp": [80, 443], "udp":[443]}"#; + let query = r#"{"tcp": [80, 443], "udp":[53]}"#; let len = query.len() as u32; tcp.write_all(&len.to_be_bytes()).unwrap(); diff --git a/skim/src/main.rs b/skim/src/main.rs index 4a82106..73bc15e 100644 --- a/skim/src/main.rs +++ b/skim/src/main.rs @@ -1,4 +1,4 @@ -use std::{cell::UnsafeCell, error::Error, net::Ipv4Addr, rc::Rc, thread::JoinHandle}; +use std::{error::Error, net::Ipv4Addr, rc::Rc, thread::JoinHandle}; use count::Count; use ethertype::EtherType; @@ -195,7 +195,7 @@ fn stat(rx: Receiver) { let udp_rx = per_spawn_cat.udp_rx_slice(); udp_ports.into_iter().for_each(|p| { - resp.tcp.push(PortNetworkPair { + resp.udp.push(PortNetworkPair { port: p, tx: udp_tx[p as usize], rx: udp_rx[p as usize], -- cgit 1.4.1-3-g733a5