Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/trippy-tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trippy-core.workspace = true
trippy-privilege.workspace = true
trippy-dns.workspace = true
anyhow.workspace = true
chrono = { workspace = true, default-features = false, features = ["clock"] }
chrono = { workspace = true, default-features = false, features = ["clock", "serde"] }
clap = { workspace = true, default-features = false, features = ["cargo", "derive", "wrap_help", "usage", "unstable-styles", "color", "suggestions", "error-context"] }
clap_complete.workspace = true
clap_mangen.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/trippy-tui/src/report/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use crate::report::types::fixed_width;
use itertools::Itertools;
use serde::Serialize;
use std::net::IpAddr;
use tracing::instrument;
use trippy_dns::Resolver;

/// Generate a CSV report of trace data.
#[instrument(skip_all, level = "trace")]
pub fn report<R: Resolver>(
info: &TraceInfo,
report_cycles: usize,
Expand Down
2 changes: 2 additions & 0 deletions crates/trippy-tui/src/report/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ use petgraph::dot::{Config, Dot};
use petgraph::graphmap::DiGraphMap;
use std::fmt::{Debug, Formatter};
use std::net::{IpAddr, Ipv4Addr};
use tracing::instrument;
use trippy_core::FlowEntry;

/// Run a trace and generate a dot file.
#[instrument(skip_all, level = "trace")]
pub fn report(info: &TraceInfo, report_cycles: usize) -> anyhow::Result<()> {
struct DotWrapper<'a>(Dot<'a, &'a DiGraphMap<IpAddr, ()>>);
impl Debug for DotWrapper<'_> {
Expand Down
2 changes: 2 additions & 0 deletions crates/trippy-tui/src/report/flows.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::app::TraceInfo;
use tracing::instrument;

/// Run a trace and report all flows observed.
#[instrument(skip_all, level = "trace")]
pub fn report(info: &TraceInfo, report_cycles: usize) -> anyhow::Result<()> {
super::wait_for_round(&info.data, report_cycles)?;
let trace = info.data.snapshot();
Expand Down
9 changes: 8 additions & 1 deletion crates/trippy-tui/src/report/json.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
use crate::app::TraceInfo;
use crate::report::types::{Hop, Host, Info, Report};
use tracing::instrument;
use trippy_dns::Resolver;

/// Generate a json report of trace data.
#[instrument(skip_all, level = "trace")]
pub fn report<R: Resolver>(
info: &TraceInfo,
report_cycles: usize,
resolver: &R,
) -> anyhow::Result<()> {
let start_timestamp = chrono::Utc::now();
let trace = super::wait_for_round(&info.data, report_cycles)?;
let end_timestamp = chrono::Utc::now();
let hops: Vec<Hop> = trace
.hops()
.iter()
Expand All @@ -20,8 +24,11 @@ pub fn report<R: Resolver>(
ip: info.data.target_addr(),
hostname: info.target_hostname.to_string(),
},
start_timestamp,
end_timestamp,
},
hops,
};
Ok(serde_json::to_writer_pretty(std::io::stdout(), &report)?)
serde_json::to_writer_pretty(std::io::stdout(), &report)?;
Ok(())
}
2 changes: 2 additions & 0 deletions crates/trippy-tui/src/report/silent.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::app::TraceInfo;
use tracing::instrument;

/// Run a trace without generating any output.
#[instrument(skip_all, level = "trace")]
pub fn report(info: &TraceInfo, report_cycles: usize) -> anyhow::Result<()> {
super::wait_for_round(&info.data, report_cycles)?;
Ok(())
Expand Down
2 changes: 2 additions & 0 deletions crates/trippy-tui/src/report/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use crate::app::TraceInfo;
use crate::report::types::Hop;
use anyhow::anyhow;
use std::thread::sleep;
use tracing::instrument;
use trippy_dns::Resolver;

/// Display a continuous stream of trace data.
#[instrument(skip_all, level = "trace")]
pub fn report<R: Resolver>(info: &TraceInfo, resolver: &R) -> anyhow::Result<()> {
println!(
"Tracing to {} ({})",
Expand Down
3 changes: 3 additions & 0 deletions crates/trippy-tui/src/report/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use crate::app::TraceInfo;
use comfy_table::presets::{ASCII_MARKDOWN, UTF8_FULL};
use comfy_table::{ContentArrangement, Table};
use itertools::Itertools;
use tracing::instrument;
use trippy_dns::Resolver;

/// Generate a Markdown table report of trace data.
#[instrument(skip_all, level = "trace")]
pub fn report_md<R: Resolver>(
info: &TraceInfo,
report_cycles: usize,
Expand All @@ -14,6 +16,7 @@ pub fn report_md<R: Resolver>(
}

/// Generate a pretty table report of trace data.
#[instrument(skip_all, level = "trace")]
pub fn report_pretty<R: Resolver>(
info: &TraceInfo,
report_cycles: usize,
Expand Down
3 changes: 3 additions & 0 deletions crates/trippy-tui/src/report/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use chrono::Utc;
use itertools::Itertools;
use serde::{Serialize, Serializer};
use std::fmt::{Display, Formatter};
Expand All @@ -14,6 +15,8 @@ pub struct Report {
#[derive(Serialize)]
pub struct Info {
pub target: Host,
pub start_timestamp: chrono::DateTime<Utc>,
pub end_timestamp: chrono::DateTime<Utc>,
}

#[derive(Serialize)]
Expand Down
Loading