Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icmp argument to allow shortcut for base protocol #788

Merged
merged 1 commit into from
Nov 13, 2023
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
8 changes: 4 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ impl TryFrom<(Args, &Platform)> for TrippyConfig {
constants::DEFAULT_REPORT_CYCLES,
);
let geoip_mmdb_file = cfg_layer_opt(args.geoip_mmdb_file, cfg_file_tui.geoip_mmdb_file);
let protocol = match (args.udp, args.tcp, protocol) {
(false, false, Protocol::Icmp) => TracerProtocol::Icmp,
(false, false, Protocol::Udp) | (true, _, _) => TracerProtocol::Udp,
(false, false, Protocol::Tcp) | (_, true, _) => TracerProtocol::Tcp,
let protocol = match (args.udp, args.tcp, args.icmp, protocol) {
(false, false, false, Protocol::Udp) | (true, _, _, _) => TracerProtocol::Udp,
(false, false, false, Protocol::Tcp) | (_, true, _, _) => TracerProtocol::Tcp,
(false, false, false, Protocol::Icmp) | (_, _, true, _) => TracerProtocol::Icmp,
};
let read_timeout = humantime::parse_duration(&read_timeout)?;
let min_round_duration = humantime::parse_duration(&min_round_duration)?;
Expand Down
23 changes: 21 additions & 2 deletions src/config/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,32 @@ pub struct Args {
pub protocol: Option<Protocol>,

/// Trace using the UDP protocol
#[arg(long, conflicts_with = "protocol", conflicts_with = "tcp")]
#[arg(
long,
conflicts_with = "protocol",
conflicts_with = "tcp",
conflicts_with = "icmp"
)]
pub udp: bool,

/// Trace using the TCP protocol
#[arg(long, conflicts_with = "protocol", conflicts_with = "udp")]
#[arg(
long,
conflicts_with = "protocol",
conflicts_with = "udp",
conflicts_with = "icmp"
)]
pub tcp: bool,

/// Trace using the ICMP protocol
#[arg(
long,
conflicts_with = "protocol",
conflicts_with = "udp",
conflicts_with = "tcp"
)]
pub icmp: bool,

/// Use IPv4 only
#[arg(short = '4', long, conflicts_with = "ipv6")]
pub ipv4: bool,
Expand Down
Loading