diff options
| author | tv <tv@krebsco.de> | 2026-10-30 18:11:57 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-30 18:11:57 +0100 |
| commit | 46a7d204c81b002f960a9bca97941df7a98c43d4 (patch) | |
| tree | dcf519abd3b5e48dd3c768648fc4d5dca03d6ce3 /src/transport | |
| parent | f65ecfdf313658a3979a2d0add53e342ce4b97df (diff) | |
dashboard: show all links between peers
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/mod.rs | 12 | ||||
| -rw-r--r-- | src/transport/wire.rs | 18 |
2 files changed, 23 insertions, 7 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index a15a1f7..9d28212 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -428,6 +428,18 @@ pub(crate) struct Link { pub(crate) rtt_us: Option<u32>, /// Silent for long (`peers.md`, dormancy). pub(crate) dormant: bool, + /// The peer's other transports (`swarm::links::MAX_OTHERS` at most): where else + /// it proved itself, those paths up. + pub(crate) others: Vec<OtherPath>, +} + +/// A transport of a link besides the one in use, in a LINKS_REPLY. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub(crate) struct OtherPath { + /// Its scheme (`mycelium`, `libp2p`, `tor`). + pub(crate) transport: String, + /// The round trip of its fastest path, in microseconds, if any is measured. + pub(crate) rtt_us: Option<u32>, } #[derive(Clone, Serialize, Deserialize)] diff --git a/src/transport/wire.rs b/src/transport/wire.rs index 3e1ab10..87063d2 100644 --- a/src/transport/wire.rs +++ b/src/transport/wire.rs @@ -14,7 +14,7 @@ use super::{MessageKind, ParsedMessage}; /// The wire format's version, the first byte of every payload. Bump it with every change /// to a message type or a codec (`golden_bytes` fails then). -pub(crate) const VERSION: u8 = 7; +pub(crate) const VERSION: u8 = 8; /// What the second byte of a payload says. fn tag(kind: MessageKind) -> u8 { @@ -419,6 +419,10 @@ pub(crate) fn samples() -> Vec<ParsedMessage> { relayed: true, rtt_us: Some(1500), dormant: false, + others: vec![crate::transport::OtherPath { + transport: "mycelium".into(), + rtt_us: None, + }], }], }), ] @@ -591,7 +595,7 @@ mod tests { }); assert_eq!( hex(&encode(&hello).unwrap()), - format!("070097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) + format!("080097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) ); let reply = ParsedMessage::HelloReply(HelloReply { @@ -611,7 +615,7 @@ mod tests { assert_eq!( hex(&encode(&reply).unwrap()), format!( - "070199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", + "080199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", run("04"), run("06") ) @@ -626,7 +630,7 @@ mod tests { }); assert_eq!( hex(&encode(&status).unwrap()), - format!("0703959290c400{epoch_hex}01c3c2") + format!("0803959290c400{epoch_hex}01c3c2") ); let who = ParsedMessage::Who(IdentityProof { @@ -635,7 +639,7 @@ mod tests { }); assert_eq!( hex(&encode(&who).unwrap()), - format!("070692c420{}c440{}", "08".repeat(32), "09".repeat(64)) + format!("080692c420{}c440{}", "08".repeat(32), "09".repeat(64)) ); let ParsedMessage::Me(proof) = decode( &encode(&ParsedMessage::Me(IdentityProof { @@ -649,10 +653,10 @@ mod tests { }; assert_eq!((proof.key, proof.signature), ([8; 32], [9; 64])); - assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "070807"); + assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "080807"); assert_eq!( hex(&encode(&ParsedMessage::Pong(u64::MAX)).unwrap()), - "0709cfffffffffffffffff" + "0809cfffffffffffffffff" ); let ParsedMessage::Pong(nonce) = decode(&[VERSION, 9, 0x2a]).unwrap() else { panic!("not a PONG"); |
