Skip to content

Commit 5aa9535

Browse files
authored
Add timestamp suffix for capture files (#58)
1 parent 75fba8b commit 5aa9535

File tree

6 files changed

+211
-4
lines changed

6 files changed

+211
-4
lines changed

Cargo.lock

Lines changed: 202 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oryx-tui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ env_logger = "0.11"
2929
serde_json = "1"
3030
serde = { version = "1", features = ["derive"] }
3131
regex = "1"
32+
chrono = "0.4"
3233

3334
[[bin]]
3435
name = "oryx"

oryx-tui/src/export.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::{
44
os::unix::fs::chown,
55
};
66

7+
use chrono::Local;
8+
79
use crate::{
810
app::AppResult,
911
packet::{
@@ -15,14 +17,16 @@ use crate::{
1517
pub fn export(packets: &[AppPacket]) -> AppResult<()> {
1618
let uid = unsafe { libc::geteuid() };
1719

20+
let local_date = Local::now().format("%Y-%m-%d_%H-%M");
21+
1822
let oryx_export_dir = dirs::home_dir().unwrap().join("oryx");
1923

2024
if !oryx_export_dir.exists() {
2125
create_dir(&oryx_export_dir)?;
2226
chown(&oryx_export_dir, Some(uid), Some(uid))?;
2327
}
2428

25-
let oryx_export_file = oryx_export_dir.join("capture");
29+
let oryx_export_file = oryx_export_dir.join(format!("capture-{local_date}"));
2630

2731
let mut file = OpenOptions::new()
2832
.create(true)

oryx-tui/src/filter/fuzzy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Fuzzy {
145145
}
146146
}
147147

148-
pub fn highlight(pattern: &str, input: String) -> Cell {
148+
pub fn highlight(pattern: &str, input: String) -> Cell<'_> {
149149
if !pattern.is_empty() {
150150
if input.contains(pattern) {
151151
let splits = input.split(pattern);

oryx-tui/src/section.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Section {
6161
firewall: Firewall::new(firewall_chans.ingress.sender, firewall_chans.egress.sender),
6262
}
6363
}
64-
fn title_span(&self, header_section: FocusedSection) -> Span {
64+
fn title_span(&self, header_section: FocusedSection) -> Span<'_> {
6565
let is_focused = self.focused_section == header_section;
6666
match header_section {
6767
FocusedSection::Inspection => {

oryx-tui/src/section/inspection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl Inspection {
146146
match export::export(&app_packets) {
147147
Ok(_) => {
148148
Notification::send(
149-
"Packets exported to ~/oryx/capture file".to_string(),
149+
"Packets exported to ~/oryx directory".to_string(),
150150
NotificationLevel::Info,
151151
event_sender,
152152
)?;

0 commit comments

Comments
 (0)