diff options
| author | tv <tv@krebsco.de> | 2026-10-26 05:54:53 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 05:54:53 +0100 |
| commit | 13abdec6dd79529143acefeaf9f8f4ac394c2db5 (patch) | |
| tree | 895419552afd3323636d334a6684d8423361e7ad /src/transport | |
| parent | 355f6db0b15e623a18626ac90c8baed10f23bef5 (diff) | |
number handshakes
This prevents late hellos from resetting the session.
Diffstat (limited to 'src/transport')
| -rw-r--r-- | src/transport/mod.rs | 4 | ||||
| -rw-r--r-- | src/transport/wire.rs | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index b2ce63f..614ac48 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -256,6 +256,10 @@ pub struct HelloRequest { /// Random per run of the sender; the reply echoes it. #[serde(with = "crate::transport::wire::codec::run_id")] pub run_id: RunId, + /// The handshake's number: the sender numbers the handshakes it starts in a run, + /// with all peers, from 1. A retry carries the same number, so the recipient resets + /// its sync session only for a new handshake, not for every resend or late copy. + pub handshake: u32, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/transport/wire.rs b/src/transport/wire.rs index 8a8cbb8..e055393 100644 --- a/src/transport/wire.rs +++ b/src/transport/wire.rs @@ -271,6 +271,7 @@ mod tests { auth: vec![1, 2, 3], ready: true, run_id: [4; 16], + handshake: 7, }); let ParsedMessage::Hello(decoded) = decode(&encode(&hello).unwrap()).unwrap() else { panic!("not a HELLO"); @@ -279,6 +280,7 @@ mod tests { assert_eq!((decoded.epoch, decoded.epoch_seq), (epoch, 1)); assert_eq!(decoded.auth, vec![1, 2, 3]); assert_eq!(decoded.run_id, [4; 16]); + assert_eq!(decoded.handshake, 7); let reply = ParsedMessage::HelloReply(HelloReply { swarm_id: "swarm".into(), |
