mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2026-10-21 14:41:22 +00:00
v0.3.0
This commit is contained in:
parent
f324e976f1
commit
f5224fa3ef
2 changed files with 11 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "sniffnet"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
description = "Application to sniff and filter network traffic. Generates a human-readable report of the observed packets."
|
||||
repository = "https://github.com/Crirock/pdsproject"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
//! If the ```-i``` option is not specified, the report is updated every 5 seconds.
|
||||
|
||||
use std::cmp::Ordering::Equal;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashMap;
|
||||
//use std::collections::HashSet;
|
||||
use std::fs::File;
|
||||
use std::sync::{Arc, Condvar, Mutex};
|
||||
use std::thread;
|
||||
|
|
@ -64,7 +65,7 @@ pub fn sleep_and_write_report_loop(lowest_port: u16, highest_port: u16, interval
|
|||
let cvar = &status_pair.1;
|
||||
let first_timestamp = Local::now().format("%d/%m/%Y %H:%M:%S").to_string();
|
||||
|
||||
let mut set_unknown = HashSet::new();
|
||||
//let mut set_unknown = HashSet::new();
|
||||
|
||||
loop {
|
||||
thread::sleep(Duration::from_secs(interval));
|
||||
|
|
@ -72,7 +73,7 @@ pub fn sleep_and_write_report_loop(lowest_port: u16, highest_port: u16, interval
|
|||
times_report_updated += 1;
|
||||
let mut output = File::create(output_file.clone()).expect("Error creating output file\n\r");
|
||||
|
||||
let mut output2 = File::create("unknown_ports.txt").expect("Error creating output file\n\r");
|
||||
//let mut output2 = File::create("unknown_ports.txt").expect("Error creating output file\n\r");
|
||||
|
||||
let map_sniffed_filtered_app = mutex_map.lock().expect("Error acquiring mutex\n\r");
|
||||
|
||||
|
|
@ -90,12 +91,12 @@ pub fn sleep_and_write_report_loop(lowest_port: u16, highest_port: u16, interval
|
|||
for (key, val) in sorted_vec.iter() {
|
||||
if val.transmitted_packets + val.received_packets >= min_packets {
|
||||
write!(output, "{}\n{}\n\n", key, val).expect("Error writing output file\n\r");
|
||||
if val.app_protocols.len() == 0 && key.port < 49152{
|
||||
set_unknown.insert(key.port);
|
||||
let mut sorted_set: Vec<&u16> = set_unknown.iter().collect();
|
||||
sorted_set.sort();
|
||||
write!(output2, "{:?}\n",sorted_set).unwrap();
|
||||
}
|
||||
// if val.app_protocols.len() == 0 && key.port < 49152{
|
||||
// set_unknown.insert(key.port);
|
||||
// let mut sorted_set: Vec<&u16> = set_unknown.iter().collect();
|
||||
// sorted_set.sort();
|
||||
// write!(output2, "{:?}\n",sorted_set).unwrap();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue