pub struct Builder { /* private fields */ }Expand description
Build a tracer.
This is a convenience builder to simplify the creation of execution of a tracer.
§Examples
use trippy_core::{Builder, MultipathStrategy, Port, PortDirection, PrivilegeMode, Protocol};
let addr = std::net::IpAddr::from([1, 2, 3, 4]);
let tracer = Builder::new(addr)
.privilege_mode(PrivilegeMode::Unprivileged)
.protocol(Protocol::Udp)
.multipath_strategy(MultipathStrategy::Dublin)
.port_direction(PortDirection::FixedBoth(Port(33434), Port(3500)))
.build()?;§See Also
Tracer- A traceroute implementation.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new(target_addr: IpAddr) -> Self
pub fn new(target_addr: IpAddr) -> Self
Build a tracer builder for a given target.
§Examples
Basic usage:
use trippy_core::Builder;
let addr = std::net::IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).build()?;Sourcepub fn source_addr(self, source_addr: Option<IpAddr>) -> Self
pub fn source_addr(self, source_addr: Option<IpAddr>) -> Self
Set the source address.
If not set then the source address will be discovered based on the target address and the interface.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let source_addr = IpAddr::from([192, 168, 1, 1]);
let tracer = Builder::new(addr).source_addr(Some(source_addr)).build()?;Sourcepub fn interface<S: Into<String>>(self, interface: Option<S>) -> Self
pub fn interface<S: Into<String>>(self, interface: Option<S>) -> Self
Set the source interface.
If the source interface is provided it will be used to look up the IPv4 or IPv6 source address.
If not provided the source address will be determined by OS based on the target IPv4 or IPv6 address.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).interface(Some("eth0")).build()?;Sourcepub fn protocol(self, protocol: Protocol) -> Self
pub fn protocol(self, protocol: Protocol) -> Self
Set the protocol.
§Examples
use std::net::IpAddr;
use trippy_core::{Builder, Protocol};
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).protocol(Protocol::Udp).build()?;Sourcepub fn trace_identifier(self, trace_id: u16) -> Self
pub fn trace_identifier(self, trace_id: u16) -> Self
Set the trace identifier.
If not set then 0 will be used as the trace identifier.
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).trace_identifier(12345).build()?;Sourcepub fn privilege_mode(self, privilege_mode: PrivilegeMode) -> Self
pub fn privilege_mode(self, privilege_mode: PrivilegeMode) -> Self
Set the privilege mode.
§Examples
use std::net::IpAddr;
use trippy_core::{Builder, PrivilegeMode};
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.privilege_mode(PrivilegeMode::Unprivileged)
.build()?;Sourcepub fn multipath_strategy(self, multipath_strategy: MultipathStrategy) -> Self
pub fn multipath_strategy(self, multipath_strategy: MultipathStrategy) -> Self
Set the multipath strategy.
§Examples
use std::net::IpAddr;
use trippy_core::{Builder, MultipathStrategy};
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.multipath_strategy(MultipathStrategy::Paris)
.build()?;Sourcepub fn packet_size(self, packet_size: u16) -> Self
pub fn packet_size(self, packet_size: u16) -> Self
Set the packet size.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).packet_size(128).build()?;Sourcepub fn payload_pattern(self, payload_pattern: u8) -> Self
pub fn payload_pattern(self, payload_pattern: u8) -> Self
Set the payload pattern.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).payload_pattern(0xff).build()?;Sourcepub fn tos(self, tos: u8) -> Self
pub fn tos(self, tos: u8) -> Self
Set the type of service.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).tos(0x1a).build()?;Sourcepub fn icmp_extension_parse_mode(
self,
icmp_extension_parse_mode: IcmpExtensionParseMode,
) -> Self
pub fn icmp_extension_parse_mode( self, icmp_extension_parse_mode: IcmpExtensionParseMode, ) -> Self
Set the ICMP extensions mode.
§Examples
use std::net::IpAddr;
use trippy_core::{Builder, IcmpExtensionParseMode};
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.icmp_extension_parse_mode(IcmpExtensionParseMode::Enabled)
.build()?;Sourcepub fn read_timeout(self, read_timeout: Duration) -> Self
pub fn read_timeout(self, read_timeout: Duration) -> Self
Set the read timeout.
§Examples
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.read_timeout(Duration::from_millis(50))
.build()?;Sourcepub fn tcp_connect_timeout(self, tcp_connect_timeout: Duration) -> Self
pub fn tcp_connect_timeout(self, tcp_connect_timeout: Duration) -> Self
Set the TCP connect timeout.
§Examples
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.tcp_connect_timeout(Duration::from_millis(100))
.build()?;Sourcepub fn max_rounds(self, max_rounds: Option<usize>) -> Self
pub fn max_rounds(self, max_rounds: Option<usize>) -> Self
Set the maximum number of rounds.
If set to None then the tracer will run indefinitely, otherwise it
will stop after the given number of rounds.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).max_rounds(Some(10)).build()?;Sourcepub fn first_ttl(self, first_ttl: u8) -> Self
pub fn first_ttl(self, first_ttl: u8) -> Self
Set the first ttl.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).first_ttl(2).build()?;Sourcepub fn max_ttl(self, max_ttl: u8) -> Self
pub fn max_ttl(self, max_ttl: u8) -> Self
Set the maximum ttl.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).max_ttl(16).build()?;Sourcepub fn grace_duration(self, grace_duration: Duration) -> Self
pub fn grace_duration(self, grace_duration: Duration) -> Self
Set the grace duration.
§Examples
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.grace_duration(Duration::from_millis(100))
.build()?;Sourcepub fn max_inflight(self, max_inflight: u8) -> Self
pub fn max_inflight(self, max_inflight: u8) -> Self
Set the max number of probes in flight at any given time.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).max_inflight(22).build()?;Sourcepub fn initial_sequence(self, initial_sequence: u16) -> Self
pub fn initial_sequence(self, initial_sequence: u16) -> Self
Set the initial sequence number.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).initial_sequence(35000).build()?;Sourcepub fn port_direction(self, port_direction: PortDirection) -> Self
pub fn port_direction(self, port_direction: PortDirection) -> Self
Set the port direction.
§Examples
use std::net::IpAddr;
use trippy_core::{Builder, Port, PortDirection};
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.port_direction(PortDirection::FixedDest(Port(8080)))
.build()?;Sourcepub fn min_round_duration(self, min_round_duration: Duration) -> Self
pub fn min_round_duration(self, min_round_duration: Duration) -> Self
Set the minimum round duration.
§Examples
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.min_round_duration(Duration::from_millis(500))
.build()?;Sourcepub fn max_round_duration(self, max_round_duration: Duration) -> Self
pub fn max_round_duration(self, max_round_duration: Duration) -> Self
Set the maximum round duration.
§Examples
use std::net::IpAddr;
use std::time::Duration;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr)
.max_round_duration(Duration::from_millis(1500))
.build()?;Sourcepub fn max_samples(self, max_samples: usize) -> Self
pub fn max_samples(self, max_samples: usize) -> Self
Set the maximum number of samples to record.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).max_samples(256).build()?;Sourcepub fn max_flows(self, max_flows: usize) -> Self
pub fn max_flows(self, max_flows: usize) -> Self
Set the maximum number of flows to record.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).max_flows(64).build()?;Sourcepub fn drop_privileges(self, drop_privileges: bool) -> Self
pub fn drop_privileges(self, drop_privileges: bool) -> Self
Drop privileges after connection is established.
§Examples
use std::net::IpAddr;
use trippy_core::Builder;
let addr = IpAddr::from([1, 1, 1, 1]);
let tracer = Builder::new(addr).drop_privileges(true).build()?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more