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 | 163963b5f17413996998a5d921b54986acb0acf1 (patch) | |
| tree | 464c0325829b808bbb672f3b55da76c5aefd8eb3 | |
| parent | 0e65743c63159786b00d0c4e3decdfd7ce199cf7 (diff) | |
ping & pong are tied by nonce only
| -rw-r--r-- | docs/openapi.yaml | 6 | ||||
| -rw-r--r-- | src/transport/paths.rs | 10 | ||||
| -rw-r--r-- | src/transport/traffic.rs | 13 |
3 files changed, 22 insertions, 7 deletions
diff --git a/docs/openapi.yaml b/docs/openapi.yaml index bb8323b..5546ac4 100644 --- a/docs/openapi.yaml +++ b/docs/openapi.yaml @@ -607,8 +607,10 @@ paths: `{"all": true}` when too many changed or the node lost count. A `messages` event lists the messages the node exchanged since the last (at most every 2 s, 500 at most): `seq`, `at` (Unix ms), `way` (`sent`, `received`, - `refused`), `peer`, `type` (`SYNC`, …), `counted` (its traffic kind), `bytes` - and `text` (the message written out). When the node + `refused`), `peer` (its node ID; the address for the paths layer's own PINGs + and PONGs), `type` (`SYNC`, …), `counted` (its traffic kind), `bytes`, + `text` (the message written out) and, where it belongs to an exchange, + `related` (the same for every message of it). When the node stops, an `offline` event ends the stream (a client reconnects once the node is back). Nothing changed, nothing is sent but keep-alive comments. Ages (`…SecsAgo`, `secsAgo`, `uptimeSecs`, `dormantForSecs`, 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; } |
