Skip to content

Commit

Permalink
update detection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Sep 24, 2024
1 parent 0ad018b commit f7aa772
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions oryx-tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,28 @@ impl App {
let packets = packets.clone();
let syn_flood_map = syn_flood_map.clone();
let syn_flood_attck_detected = syn_flood_attck_detected.clone();
let win_size = 10_000;
let win_size = 100_000;
move || loop {
let start_index = {
let packets = packets.lock().unwrap();
packets.len().saturating_sub(1)
};
thread::sleep(Duration::from_secs(5));
let app_packets = {
let packets = packets.lock().unwrap();
packets.clone()
};

let mut map = syn_flood_map.lock().unwrap();
map.clear();

if app_packets.len() < win_size {
continue;
}

let mut nb_syn_packets = 0;

app_packets[app_packets.len().wrapping_sub(win_size)..]
app_packets[start_index..app_packets.len().saturating_sub(1)]
.iter()
.for_each(|packet| {
if let AppPacket::Ip(ip_packet) = packet {
Expand Down Expand Up @@ -1141,6 +1146,8 @@ impl App {
};
attacker_ips.sort_by(|a, b| b.1.cmp(&a.1));

attacker_ips.retain(|(_, count)| *count > 10_000);

let top_3 = attacker_ips.into_iter().take(3);

let widths = [Constraint::Min(30), Constraint::Min(20)];
Expand Down

0 comments on commit f7aa772

Please sign in to comment.