Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyes-ced committed Dec 6, 2023
1 parent 95c3a47 commit 815ace3
Show file tree
Hide file tree
Showing 38 changed files with 77 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/display/components/header_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ impl<'a> HeaderDetails<'a> {
unit_family,
};
let paused = if self.paused { " [PAUSED]" } else { "" };
let intrf = &self.state.interface_name;
format!("Interface: <{intrf}> | Total {t} (Up / Down): {up} / {down}{paused}")
let intrf = self.state.interface_name.clone().unwrap_or("All".to_string());
format!("IF: {intrf} | Total {t} (Up / Down): {up} / {down}{paused}")
}

fn render_elapsed_time(&self, frame: &mut Frame, rect: Rect, elapsed_time: &str, color: Color) {
Expand Down
2 changes: 1 addition & 1 deletion src/display/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ where
pub fn end(&mut self) {
self.terminal.show_cursor().unwrap();
}
pub fn update_interface_name(&mut self, interface_name: String) {
pub fn update_interface_name(&mut self, interface_name: Option<String>) {
self.state.interface_name = interface_name;
}
}
2 changes: 1 addition & 1 deletion src/display/ui_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub struct UIState {
pub connections_map: HashMap<Connection, ConnectionData>,
/// Used for reducing logging noise.
known_orphan_sockets: VecDeque<LocalSocket>,
pub interface_name: String,
pub interface_name: Option<String>,
}

impl UIState {
Expand Down
6 changes: 1 addition & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ where
let mut ui = ui.lock().unwrap();
let paused = paused.load(Ordering::SeqCst);
let ui_offset = ui_offset.load(Ordering::SeqCst);
let interface = match opts.interface {
Some(ref interface_name) => interface_name.to_string(),
None => "All Interfaces".to_string(),
};
ui.update_interface_name(interface);
ui.update_interface_name(opts.interface.clone());
if !paused {
ui.update_state(sockets_to_procs, utilization, ip_to_host);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by remote address───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
Remote Address Connections Rate (Up / Down) │
│ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by connection───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
Connection Process Rate (Up / Down) │
│ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) │
│ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) │
│ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │
│ ││ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │
│ ││ │
Expand Down Expand Up @@ -54,7 +54,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

--- SECTION SEPARATOR ---
24. 0B / 25.00B
24. 0B / 25.00B


1 1 24.00B / 25.00B 1.1.1.1 1 24.00B / 25.00B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name──────────────────────────────────────────────────────────────────┐┌Utilization by remote address────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) ││Remote Address Connections Rate (Up / Down) │
│ ││ │
Expand Down Expand Up @@ -33,7 +33,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

--- SECTION SEPARATOR ---
98. 0B
98. 0B


5 1 0.00B / 28.00B 3.3.3.3 1 0.00B / 28.00B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) │
│ │
Expand Down Expand Up @@ -54,7 +54,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

--- SECTION SEPARATOR ---
98. 0B
98. 0B


5 1 0.00B / 28.00B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name──────────────────────────────────────────────────────────────────────────────────────────┐
Process Connections Rate (Up / Down) │
│ │
Expand Down Expand Up @@ -33,7 +33,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause. Use <TAB> to rearrange tables. (DNS queries hidden).

--- SECTION SEPARATOR ---
98. 0B
98. 0B


5 1 0.00B / 28.00B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B
Utilization by process name─────────────────────┐
Process Rate (Up / Down) │
│ │
Expand Down Expand Up @@ -54,7 +54,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause.

--- SECTION SEPARATOR ---
98. 0B


5 0.00B / 28.00B
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: src/tests/cases/ui.rs
expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR)
---
Total Rate (Up / Down): 0.00B / 0.00B
IF: interface_name | Total Rate (Up / Down): 0.00B / 0.00B
Utilization by process name────────────────────────────────────────┐
Process Connections Rate (Up / Down) │
│ │
Expand Down Expand Up @@ -33,7 +33,7 @@ expression: terminal_draw_events.lock().unwrap().join(SNAPSHOT_SECTION_SEPARATOR
Press <SPACE> to pause. Use <TAB> to rearrange tables.

--- SECTION SEPARATOR ---
98. 0B
98. 0B


5 1 0.00B / 28.00B
Expand Down
Loading

0 comments on commit 815ace3

Please sign in to comment.