Skip to content

Commit

Permalink
docs: fix spelling and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Dec 24, 2024
1 parent cb305a9 commit da6735d
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion crates/trippy-core/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ mod tests {
.unwrap();

assert_eq!(TARGET_ADDR, tracer.target_addr());
// note that source_addr is not set until the tracer is run
// note that `source_addr` is not set until the tracer is run
assert_eq!(None, tracer.source_addr());
assert_eq!(Some("eth0"), tracer.interface());
assert_eq!(10, tracer.max_samples());
Expand Down
4 changes: 2 additions & 2 deletions crates/trippy-core/src/net/ipv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ mod tests {
Ok(())
}

// This IPv4/ICMP TimeExceeded packet has code 1 ("Fragment reassembly
// This IPv4/ICMP `TimeExceeded` packet has code 1 ("Fragment reassembly
// time exceeded") and must be ignored.
//
// Note this is not real packet and so the length and checksum are not
Expand Down Expand Up @@ -1726,7 +1726,7 @@ mod tests {
Ok(())
}

// This IPv4/ICMP TimeExceeded packet has an UDP Original Datagram
// This IPv4/ICMP `TimeExceeded` packet has an UDP Original Datagram
// with a bogus length (claimed 2040 vs actual 56).
//
// This is a test to ensure that the UDP checksum validation is working for
Expand Down
4 changes: 2 additions & 2 deletions crates/trippy-core/src/net/ipv6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Ipv6 {
udp_send_socket.set_unicast_hops_v6(probe.ttl.0)?;
// Note that we set the port to be 0 in the remote `SocketAddr` as the target port is
// encoded in the `UDP` packet. If we (redundantly) set the target port here then
// the send_to will fail with `EINVAL`.
// the `send_to` will fail with `EINVAL`.
let remote_addr = SocketAddr::new(IpAddr::V6(self.dest_addr), 0);
udp_send_socket.send_to(udp.packet(), remote_addr)?;
Ok(())
Expand Down Expand Up @@ -1284,7 +1284,7 @@ mod tests {
Ok(())
}

// Here we receive a TimeExceeded in UDP/Dublin mode and so extract the
// Here we receive a `TimeExceeded` in UDP/Dublin mode and so extract the
// sequence from the length of the UDP payload, after subtracting the
// length of the magic prefix "trippy" (11 - 6 == 5).
//
Expand Down
16 changes: 8 additions & 8 deletions crates/trippy-core/src/net/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,25 +257,25 @@ impl SocketImpl {

#[allow(unsafe_code)]
const fn new_wsa_data() -> WSADATA {
// Safety: an all-zero value is valid for WSADATA.
// Safety: an all-zero value is valid for `WSADATA`.
unsafe { zeroed::<WSADATA>() }
}

#[allow(unsafe_code)]
const fn new_sockaddr_storage() -> SOCKADDR_STORAGE {
// Safety: an all-zero value is valid for SOCKADDR_STORAGE.
// Safety: an all-zero value is valid for `SOCKADDR_STORAGE`.
unsafe { zeroed::<SOCKADDR_STORAGE>() }
}

#[allow(unsafe_code)]
const fn new_overlapped() -> OVERLAPPED {
// Safety: an all-zero value is valid for OVERLAPPED.
// Safety: an all-zero value is valid for `OVERLAPPED.`
unsafe { zeroed::<OVERLAPPED>() }
}

#[allow(unsafe_code)]
const fn new_icmp_error_info() -> ICMP_ERROR_INFO {
// Safety: an all-zero value is valid for ICMP_ERROR_INFO.
// Safety: an all-zero value is valid for `ICMP_ERROR_INFO`.
unsafe { zeroed::<ICMP_ERROR_INFO>() }
}
}
Expand Down Expand Up @@ -580,7 +580,7 @@ impl Socket for SocketImpl {
}
}

// Interestingly, Socket2 sockets don't seem to call closesocket on drop??
// Interestingly, `Socket2` sockets don't seem to call `closesocket` on drop??
#[instrument(skip(self))]
fn close(&mut self) -> IoResult<()> {
syscall!(closesocket(self.inner.as_raw_socket() as _), |res| res
Expand All @@ -590,7 +590,7 @@ impl Socket for SocketImpl {
}
}

// Note that we handle `WSAENOBUFS`, which can occurs when calling send_to()
// Note that we handle `WSAENOBUFS`, which can occurs when calling `send_to()`
// for ICMP and UDP. We return it as `NetUnreachable` to piggyback on the
// existing error handling.
impl From<&StdIoError> for ErrorKind {
Expand Down Expand Up @@ -651,7 +651,7 @@ fn routing_interface_query(target: IpAddr) -> Result<IpAddr> {
|res| res == SOCKET_ERROR
)
.map_err(|err| IoError::Other(err, IoOperation::SioRoutingInterfaceQuery))?;
// Note that the WSAIoctl call potentially returns multiple results (see
// Note that the `WSAIoctl` call potentially returns multiple results (see
// <https://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedsocketoptionioctl7h.html>),
// TBD We choose the first one arbitrarily.
let sockaddr = src.cast::<SOCKADDR_STORAGE>();
Expand Down Expand Up @@ -879,7 +879,7 @@ mod adapter {
if self.next.is_null() {
None
} else {
// Safety: `next` is not null and points to a valid IP_ADAPTER_ADDRESSES_LH
// Safety: `next` is not null and points to a valid `IP_ADAPTER_ADDRESSES_LH`
#[allow(unsafe_code)]
unsafe {
let friendly_name = WideCString::from_ptr_str((*self.next).FriendlyName)
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-core/src/net/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
fn send_to(&mut self, buf: &[u8], addr: SocketAddr) -> Result<()>;
/// Returns true if the socket becomes readable before the timeout, false otherwise.
fn is_readable(&mut self, timeout: Duration) -> Result<bool>;
/// Returns true if the socket is currently writeable, false otherwise.
/// Returns true if the socket is currently writable, false otherwise.
fn is_writable(&mut self) -> Result<bool>;
fn recv_from(&mut self, buf: &mut [u8]) -> Result<(usize, Option<SocketAddr>)>;
fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
Expand Down
4 changes: 2 additions & 2 deletions crates/trippy-core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,15 @@ mod tests {
type Error = anyhow::Error;

fn try_from(value: String) -> Result<Self, Self::Error> {
// format: {ttl} {status} {duration} {host} {sequence} {src_port} {dest_port} {checksum}
// format: `{ttl} {status} {duration} {host} {sequence} {src_port} {dest_port} {checksum}`
let values = value.split_ascii_whitespace().collect::<Vec<_>>();
if values.len() == 9 {
let ttl = TimeToLive(u8::from_str(values[0])?);
let state = values[1].to_ascii_lowercase();
let sequence = Sequence(u16::from_str(values[4])?);
let src_port = Port(u16::from_str(values[5])?);
let dest_port = Port(u16::from_str(values[6])?);
let round = RoundId(0); // note we inject this later, see ProbeRound
let round = RoundId(0); // note we inject this later, see `ProbeRound`
let sent = SystemTime::now();
let flags = Flags::empty();
let state = match state.as_str() {
Expand Down
22 changes: 11 additions & 11 deletions crates/trippy-core/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ mod state {

/// Advance to the next round.
///
/// If, during the rond which just completed, we went above the max sequence number then we
/// If, during the round which just completed, we went above the max sequence number then we
/// reset it here. We do this here to avoid having to deal with the sequence number
/// wrapping during a round, which is more problematic.
#[instrument(skip(self))]
Expand Down Expand Up @@ -1278,7 +1278,7 @@ mod state {
fn test_state() {
let mut state = TracerState::new(cfg(Sequence(33434)));

// Validate the initial TracerState
// Validate the initial `TracerState`
assert_eq!(state.round, RoundId(0));
assert_eq!(state.sequence, Sequence(33434));
assert_eq!(state.round_sequence, Sequence(33434));
Expand All @@ -1300,7 +1300,7 @@ mod state {
assert_eq!(probe_1.round, RoundId(0));
assert_eq!(probe_1.sent, sent_1);

// Update the state of the probe 1 after receiving a TimeExceeded
// Update the state of the probe 1 after receiving a `TimeExceeded`
let received_1 = SystemTime::now();
let host = IpAddr::V4(Ipv4Addr::LOCALHOST);
state.complete_probe(StrategyResponse {
Expand Down Expand Up @@ -1328,7 +1328,7 @@ mod state {
IcmpPacketType::TimeExceeded(IcmpPacketCode(1))
);

// Validate the TracerState after the update
// Validate the `TracerState` after the update
assert_eq!(state.round, RoundId(0));
assert_eq!(state.sequence, Sequence(33435));
assert_eq!(state.round_sequence, Sequence(33434));
Expand All @@ -1349,7 +1349,7 @@ mod state {
// Advance to the next round
state.advance_round(TimeToLive(1));

// Validate the TracerState after the round update
// Validate the `TracerState` after the round update
assert_eq!(state.round, RoundId(1));
assert_eq!(state.sequence, Sequence(33435));
assert_eq!(state.round_sequence, Sequence(33435));
Expand All @@ -1375,7 +1375,7 @@ mod state {
assert_eq!(probe_3.round, RoundId(1));
assert_eq!(probe_3.sent, sent_3);

// Update the state of probe 2 after receiving a TimeExceeded
// Update the state of probe 2 after receiving a `TimeExceeded`
let received_2 = SystemTime::now();
let host = IpAddr::V4(Ipv4Addr::LOCALHOST);
state.complete_probe(StrategyResponse {
Expand All @@ -1391,7 +1391,7 @@ mod state {
});
let probe_2_recv = state.probe_at(Sequence(33435));

// Validate the TracerState after the update to probe 2
// Validate the `TracerState` after the update to probe 2
assert_eq!(state.round, RoundId(1));
assert_eq!(state.sequence, Sequence(33437));
assert_eq!(state.round_sequence, Sequence(33435));
Expand All @@ -1410,7 +1410,7 @@ mod state {
assert_eq!(ProbeStatus::Awaited(probe_3), probe_next2.clone());
}

// Update the state of probe 3 after receiving a EchoReply
// Update the state of probe 3 after receiving a `EchoReply`
let received_3 = SystemTime::now();
let host = IpAddr::V4(Ipv4Addr::LOCALHOST);
state.complete_probe(StrategyResponse {
Expand All @@ -1426,7 +1426,7 @@ mod state {
});
let probe_3_recv = state.probe_at(Sequence(33436));

// Validate the TracerState after the update to probe 3
// Validate the `TracerState` after the update to probe 3
assert_eq!(state.round, RoundId(1));
assert_eq!(state.sequence, Sequence(33437));
assert_eq!(state.round_sequence, Sequence(33435));
Expand All @@ -1448,7 +1448,7 @@ mod state {

#[test]
fn test_sequence_wrap1() {
// Start from MAX_SEQUENCE - 1 which is (65279 - 1) == 65278
// Start from `MAX_SEQUENCE` - 1 which is (65279 - 1) == 65278
let initial_sequence = Sequence(65278);
let mut state = TracerState::new(cfg(initial_sequence));
assert_eq!(state.round, RoundId(0));
Expand Down Expand Up @@ -1478,7 +1478,7 @@ mod state {
.for_each(|p| assert!(matches!(p, ProbeStatus::NotSent)));
}

// Advance the round, which will wrap the sequence back to initial_sequence
// Advance the round, which will wrap the sequence back to `initial_sequence`
state.advance_round(TimeToLive(1));
assert_eq!(state.round, RoundId(1));
assert_eq!(state.sequence, initial_sequence);
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-core/src/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl Tracer {
self.inner.grace_duration()
}

/// The maximum number of inflight probes of the tracer.
/// The maximum number of in-flight probes of the tracer.
#[must_use]
pub fn max_inflight(&self) -> MaxInflight {
self.inner.max_inflight()
Expand Down
12 changes: 6 additions & 6 deletions crates/trippy-dns/src/lazy_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ pub enum ResolveMethod {
/// How to resolve IP addresses.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum IpAddrFamily {
/// Lookup Ipv4 only.
/// Lookup IPv4 only.
Ipv4Only,
/// Lookup Ipv6 only.
/// Lookup IPv6 only.
Ipv6Only,
/// Lookup Ipv6 with a fallback to Ipv4
/// Lookup IPv6 with a fallback to IPv4
Ipv6thenIpv4,
/// Lookup Ipv4 with a fallback to Ipv6
/// Lookup IPv4 with a fallback to IPv6
Ipv4thenIpv6,
}

Expand Down Expand Up @@ -300,7 +300,7 @@ mod inner {
_ => {}
}

// If the entry exists but has timed out, then set it as DnsEntry::Pending and enqueue
// If the entry exists but has timed out, then set it as `DnsEntry::Pending` and enqueue
// it again.
if let DnsEntry::Timeout(addr) = dns_entry.entry {
*self
Expand All @@ -315,7 +315,7 @@ mod inner {

// If this is a newly added `DnsEntry` then send it to the channel to be resolved in the
// background. We do this after the above to ensure we aren't holding the
// lock on the cache, which is usd by the resolver and so would deadlock.
// lock on the cache, which is used by the resolver and so would deadlock.
if enqueue {
if self
.tx
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-packet/src/checksum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Checksum implementations for ICMP & UDP over IPv4 and IPV6.
//!
//! This code is derived from [`libpnet`] which is available under the Apache 2.0 licence.
//! This code is derived from [`libpnet`] which is available under the Apache 2.0 license.
//!
//! [`libpnet`]: https://github.com/libpnet/libpnet
Expand Down
6 changes: 3 additions & 3 deletions crates/trippy-packet/src/icmp_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ pub mod extension_splitter {
use crate::ipv4::Ipv4Packet;
use std::net::Ipv4Addr;

// This ICMP TimeExceeded packet which contains single `MPLS` extension
// This ICMP `TimeExceeded` packet which contains single `MPLS` extension
// object with a single member. The packet does not have a `length`
// field and is therefore rfc4884 non-complaint.
#[test]
Expand Down Expand Up @@ -1076,7 +1076,7 @@ pub mod extension_splitter {
assert_eq!(1, mpls_stack_member.get_ttl());
}

// This ICMP TimeExceeded packet does not have any ICMP extensions.
// This ICMP `TimeExceeded` packet does not have any ICMP extensions.
// It has a rfc4884 complaint `length` field.
#[test]
fn test_split_extension_ipv4_time_exceeded_compliant_no_extension() {
Expand Down Expand Up @@ -1120,7 +1120,7 @@ pub mod extension_splitter {
// an original datagram if length 68 octet (17 * 4 = 68) but is padded
// to be 128 octets.
//
// See https://github.com/fujiapple852/trippy/issues/804 for further
// See `https://github.com/fujiapple852/trippy/issues/804` for further
// discussion and analysis of this case.
#[test]
fn test_split_extension_ipv4_time_exceeded_compliant_extension() {
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-privilege/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub enum Error {
GetTokenInformationError,
}

/// Runtime platform privilege information.
/// Run-time platform privilege information.
#[derive(Debug)]
pub struct Privilege {
has_privileges: bool,
Expand Down
8 changes: 4 additions & 4 deletions crates/trippy-tui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ impl From<Protocol> for ProtocolConfig {
#[derive(Debug, Copy, Clone, Eq, PartialEq, ValueEnum, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum AddressFamilyConfig {
/// Ipv4 only.
/// IPv4 only.
Ipv4,
/// Ipv6 only.
/// IPv6 only.
Ipv6,
/// Ipv6 with a fallback to Ipv4
/// IPv6 with a fallback to IPv4
#[serde(rename = "ipv6-then-ipv4")]
Ipv6ThenIpv4,
/// Ipv4 with a fallback to Ipv6
/// IPv4 with a fallback to IPv6
#[serde(rename = "ipv4-then-ipv6")]
Ipv4ThenIpv6,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-tui/src/config/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ pub enum TuiCommandItem {
ToggleSettingsTrace,
/// Toggle the DNS settings dialog tab.
ToggleSettingsDns,
/// Toggle the Geoip settings dialog tab.
/// Toggle the `GeoIp` settings dialog tab.
ToggleSettingsGeoip,
/// Toggle the bindings settings dialog tab.
ToggleSettingsBindings,
Expand Down
2 changes: 1 addition & 1 deletion crates/trippy-tui/src/config/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod tests {
assert!(TuiColumn::try_from(c).is_err());
}

///Test for TuiColumn type match of Display
///Test for `TuiColumn` type match of Display
#[test_case(TuiColumn::Ttl, "h")]
#[test_case(TuiColumn::Host, "o")]
#[test_case(TuiColumn::LossPct, "l")]
Expand Down
4 changes: 2 additions & 2 deletions crates/trippy-tui/src/geoip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod ipinfo {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

/// ipinfo.io's mmdb database format.
/// The IPinfo mmdb database format.
///
/// Support both the "IP to Geolocation Extended" and "IP to Country + ASN" database formats.
///
Expand Down Expand Up @@ -284,7 +284,7 @@ impl From<(maxminddb::geoip2::City<'_>, &str)> for GeoIpCity {
/// > and German.
/// >
/// > Please note: Not every place name is always available in each language. We recommend checking
/// > English names as a default for cases where a localized name isn’t available in your preferred
/// > English names as a default for cases where a localized name is not available in your preferred
/// > language.
const FALLBACK_LOCALE: &str = "en";

Expand Down
Loading

0 comments on commit da6735d

Please sign in to comment.