diff options
| author | tv <tv@krebsco.de> | 2026-10-30 21:47:31 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-30 21:47:31 +0100 |
| commit | d60f59052cef6760329e3500306c7f498745216e (patch) | |
| tree | 8828b0c0a99354871ddf82c3eb698448ef0bca79 /src/transport | |
| parent | db6e1ad6592aefce8a99db8478fac0baae09b228 (diff) | |
allow links subscriptions
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/mod.rs | 4 | ||||
| -rw-r--r-- | src/transport/wire.rs | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index 7fbbd73..903dd07 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -403,6 +403,10 @@ pub(crate) struct LinksRequest { pub(crate) epoch_seq: u32, /// Repeated in the reply: which request it answers. pub(crate) nonce: u64, + /// For this long (seconds), a LINKS_REPLY again whenever the links change (a + /// subscription; the next LINKS renews it). 0: this reply only, and a subscription + /// ends. + pub(crate) subscribe_secs: u32, } /// LINKS_REPLY: how the sender is linked to its neighbours, as it measures them. diff --git a/src/transport/wire.rs b/src/transport/wire.rs index dc94ab3..40e32a2 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 = 10; +pub(crate) const VERSION: u8 = 11; /// What the second byte of a payload says. fn tag(kind: MessageKind) -> u8 { @@ -409,6 +409,7 @@ pub(crate) fn samples() -> Vec<ParsedMessage> { epoch, epoch_seq: 1, nonce: 3, + subscribe_secs: 60, }), ParsedMessage::LinksReply(crate::transport::LinksReply { epoch, @@ -599,7 +600,7 @@ mod tests { }); assert_eq!( hex(&encode(&hello).unwrap()), - format!("0a0097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) + format!("0b0097a5737761726d{epoch_hex}01c403010203c3{}07", run("04")) ); let reply = ParsedMessage::HelloReply(HelloReply { @@ -619,7 +620,7 @@ mod tests { assert_eq!( hex(&encode(&reply).unwrap()), format!( - "0a0199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", + "0b0199a5737761726d9192a17091a161{epoch_hex}01c400c2{}05{}", run("04"), run("06") ) @@ -635,7 +636,7 @@ mod tests { }); assert_eq!( hex(&encode(&status).unwrap()), - format!("0a03969290c400{epoch_hex}01c3c2c2") + format!("0b03969290c400{epoch_hex}01c3c2c2") ); let who = ParsedMessage::Who(IdentityProof { @@ -644,7 +645,7 @@ mod tests { }); assert_eq!( hex(&encode(&who).unwrap()), - format!("0a0692c420{}c440{}", "08".repeat(32), "09".repeat(64)) + format!("0b0692c420{}c440{}", "08".repeat(32), "09".repeat(64)) ); let ParsedMessage::Me(proof) = decode( &encode(&ParsedMessage::Me(IdentityProof { @@ -658,10 +659,10 @@ mod tests { }; assert_eq!((proof.key, proof.signature), ([8; 32], [9; 64])); - assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "0a0807"); + assert_eq!(hex(&encode(&ParsedMessage::Ping(7)).unwrap()), "0b0807"); assert_eq!( hex(&encode(&ParsedMessage::Pong(u64::MAX)).unwrap()), - "0a09cfffffffffffffffff" + "0b09cfffffffffffffffff" ); let ParsedMessage::Pong(nonce) = decode(&[VERSION, 9, 0x2a]).unwrap() else { panic!("not a PONG"); |
