Skip to content

Commit

Permalink
feat(report): add nat attribute to json report
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Jul 13, 2024
1 parent 1eca88f commit 0102d94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/trippy-tui/src/report/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use itertools::Itertools;
use serde::{Serialize, Serializer};
use std::fmt::{Display, Formatter};
use std::net::IpAddr;
use trippy_core::NatStatus;
use trippy_dns::Resolver;

#[derive(Serialize)]
Expand Down Expand Up @@ -42,6 +43,7 @@ pub struct Hop {
pub jmax: f64,
#[serde(serialize_with = "fixed_width")]
pub jinta: f64,
pub nat: Option<bool>,
}

impl<R: Resolver> From<(&trippy_core::Hop, &R)> for Hop {
Expand All @@ -64,6 +66,11 @@ impl<R: Resolver> From<(&trippy_core::Hop, &R)> for Hop {
javg: value.javg_ms(),
jmax: value.jmax_ms().unwrap_or_default(),
jinta: value.jinta(),
nat: match value.last_nat_status() {
NatStatus::NotApplicable => None,
NatStatus::NotDetected => Some(false),
NatStatus::Detected => Some(true),
},
}
}
}
Expand Down

0 comments on commit 0102d94

Please sign in to comment.