diff options
| author | tv <tv@krebsco.de> | 2026-11-01 21:39:21 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 21:39:21 +0100 |
| commit | abc3f66b13daeeb55204c5a5b47152b136ce684d (patch) | |
| tree | 54e4d29390539d18fdcd52e51e3b3011e513ea22 /src | |
| parent | 98b49df1e7631f99b0ad780fb0f01924cebd0756 (diff) | |
ping & pong are tied by nonce only
Diffstat (limited to 'src')
| -rw-r--r-- | src/transport/paths.rs | 10 | ||||
| -rw-r--r-- | src/transport/traffic.rs | 13 |
2 files changed, 18 insertions, 5 deletions
diff --git a/src/transport/paths.rs b/src/transport/paths.rs index 1f88e0a..ba8581f 100644 --- a/src/transport/paths.rs +++ b/src/transport/paths.rs @@ -878,8 +878,8 @@ impl Paths { stats } - /// Sends a PING (or with `pong`, a PONG) with `nonce` to `address`, counted - /// (`traffic`). + /// Sends a PING (or with `pong`, a PONG) with `nonce` to `address`, counted and + /// logged (`traffic`). async fn send_probe(&self, address: &str, pong: bool, nonce: u64) -> Result<()> { let message = if pong { ParsedMessage::Pong { @@ -896,6 +896,12 @@ impl Paths { Ok(()) => traffic.sent(address, encoded.kind, encoded.payload_len), Err(_) => traffic.refused(address, encoded.kind, encoded.payload_len), } + // Logged too, under the address: the PINGs and PONGs that come back go up to + // the node and are logged there, and an exchange is seen whole. + let way = if sent.is_ok() { "sent" } else { "refused" }; + traffic + .log + .note(way, address, &message, encoded.payload_len); } sent } diff --git a/src/transport/traffic.rs b/src/transport/traffic.rs index 2e45a31..041471d 100644 --- a/src/transport/traffic.rs +++ b/src/transport/traffic.rs @@ -137,7 +137,8 @@ pub(crate) struct Logged { } /// What ties `message`, with `peer`, to other messages: a PING and its PONG (the -/// nonce), a LINKS and its replies (the nonce), a HELLO and its replies (the run of the +/// nonce alone: a PING may go to an address and its PONG come back up from the node +/// there, `paths`), a LINKS and its replies (the nonce), a HELLO and its replies (the run of the /// node that sent the HELLO, which the reply echoes), a blob's requests and answers, from /// any peer (its ID), and a delta offered in a SYNC with the blob it is fetched as. None /// for the rest (a STATUS and its reply carry nothing of the kind). @@ -145,7 +146,7 @@ fn related(peer: &str, message: &ParsedMessage) -> Option<String> { use crate::transport::{Hex, SyncBody}; Some(match message { ParsedMessage::Ping(nonce) | ParsedMessage::Pong { nonce, .. } => { - format!("ping {peer} {nonce}") + format!("ping {nonce}") } ParsedMessage::Links(request) => format!("links {peer} {}", request.nonce), ParsedMessage::LinksReply(reply) => format!("links {peer} {}", reply.nonce), @@ -173,7 +174,13 @@ impl MessageLog { } } - fn note(&self, way: &'static str, peer: &str, message: &ParsedMessage, bytes: usize) { + pub(crate) fn note( + &self, + way: &'static str, + peer: &str, + message: &ParsedMessage, + bytes: usize, + ) { if !self.watching.load(Ordering::Relaxed) { return; } |
