Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Oct 9, 2024
1 parent 8e30786 commit 977389f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion oryx-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use network_types::{arp::ArpHdr, icmp::IcmpHdr, ip::IpHdr, tcp::TcpHdr, udp::Udp
pub mod ip;
pub mod protocols;

pub const MAX_FIREWALL_RULES: u32 = 1;
pub const MAX_FIREWALL_RULES: u32 = 32;
pub const MAX_RULES_PORT: usize = 32;

#[repr(C)]
Expand Down
30 changes: 15 additions & 15 deletions oryx-tui/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
pub fn handle_key_events(
key_event: KeyEvent,
app: &mut App,
sender: kanal::Sender<Event>,
event_sender: kanal::Sender<Event>,
) -> AppResult<()> {
// Start Phase
if !app.start_sniffing {
match key_event.code {
KeyCode::Enter => {
if app.filter.focused_block == FocusedBlock::Apply {
app.filter
.start(sender.clone(), app.data_channel_sender.clone())?;
.start(event_sender.clone(), app.data_channel_sender.clone())?;

app.start_sniffing = true;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ pub fn handle_key_events(
ActivePopup::NewFirewallRule => {
app.section
.firewall
.handle_keys(key_event, sender.clone())?;
.handle_keys(key_event, event_sender.clone())?;
app.is_editing = false;
}
_ => {}
Expand All @@ -74,7 +74,7 @@ pub fn handle_key_events(
ActivePopup::UpdateFilters => {
if app.filter.focused_block == FocusedBlock::Apply {
app.filter
.update(sender.clone(), app.data_channel_sender.clone())?;
.update(event_sender.clone(), app.data_channel_sender.clone())?;
if !app.filter.traffic_direction.is_ingress_loaded() {
app.section.firewall.disable_ingress_rules();
}
Expand All @@ -90,7 +90,7 @@ pub fn handle_key_events(
if app
.section
.firewall
.handle_keys(key_event, sender.clone())
.handle_keys(key_event, event_sender.clone())
.is_ok()
{
app.active_popup = None;
Expand All @@ -107,7 +107,7 @@ pub fn handle_key_events(
ActivePopup::NewFirewallRule => {
app.section
.firewall
.handle_keys(key_event, sender.clone())?;
.handle_keys(key_event, event_sender.clone())?;
}
_ => {}
},
Expand All @@ -122,7 +122,7 @@ pub fn handle_key_events(
_ => {}
}

app.section.handle_keys(key_event, sender.clone())?;
app.section.handle_keys(key_event, event_sender.clone())?;
return Ok(());
}

Expand All @@ -140,7 +140,7 @@ pub fn handle_key_events(
if key_event.modifiers == KeyModifiers::CONTROL {
app.filter.terminate();
thread::sleep(Duration::from_millis(150));
sender.send(Event::Reset)?;
event_sender.send(Event::Reset)?;
}
}

Expand All @@ -161,13 +161,13 @@ pub fn handle_key_events(
KeyCode::Char('/') => {
if app.section.focused_section == FocusedSection::Inspection {
app.is_editing = true;
app.section.handle_keys(key_event, sender.clone())?;
app.section.handle_keys(key_event, event_sender.clone())?;
}
}

KeyCode::Char('n') | KeyCode::Char('e') => {
if app.section.focused_section == FocusedSection::Firewall
&& app.section.handle_keys(key_event, sender).is_ok()
&& app.section.handle_keys(key_event, event_sender).is_ok()
{
app.is_editing = true;
app.active_popup = Some(ActivePopup::NewFirewallRule);
Expand All @@ -183,7 +183,7 @@ pub fn handle_key_events(
KeyCode::Char(' ') => {
if app.section.focused_section == FocusedSection::Firewall {
app.section.firewall.load_rule(
sender.clone(),
event_sender.clone(),
app.filter.traffic_direction.is_ingress_loaded(),
app.filter.traffic_direction.is_egress_loaded(),
)?;
Expand All @@ -196,25 +196,25 @@ pub fn handle_key_events(
Notification::send(
"There is no packets".to_string(),
NotificationLevel::Info,
sender,
event_sender,
)?;
} else {
match export(&app_packets) {
Ok(_) => {
Notification::send(
"Packets exported to ~/oryx/capture file".to_string(),
NotificationLevel::Info,
sender,
event_sender,
)?;
}
Err(e) => {
Notification::send(e.to_string(), NotificationLevel::Error, sender)?;
Notification::send(e.to_string(), NotificationLevel::Error, event_sender)?;
}
}
}
}
_ => {
app.section.handle_keys(key_event, sender.clone())?;
app.section.handle_keys(key_event, event_sender.clone())?;
}
}

Expand Down

0 comments on commit 977389f

Please sign in to comment.