diff options
| author | tv <tv@krebsco.de> | 2026-10-22 20:37:34 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-22 20:37:34 +0200 |
| commit | c97161adb3142041c00d649a51924318b5a2d6e4 (patch) | |
| tree | 5a6a9ed95c9f4745fe5fe9a5dd262563e24bd572 /src/transport/mycelium.rs | |
| parent | d332830dfee1c6da4726cd69698f9edd18a33e0e (diff) | |
introduce pre-shared swarm key
Diffstat (limited to 'src/transport/mycelium.rs')
| -rw-r--r-- | src/transport/mycelium.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/transport/mycelium.rs b/src/transport/mycelium.rs index dc2c66e..0c0093a 100644 --- a/src/transport/mycelium.rs +++ b/src/transport/mycelium.rs @@ -795,6 +795,8 @@ fn bytes_to_keepalive(bytes: &[u8]) -> Result<Keepalive, TransportError> { pub struct HelloRequestShadow { #[serde(default)] epoch: EpochShadow, + #[serde(default)] + auth: ByteBuf, } #[derive(Serialize, Deserialize)] @@ -805,6 +807,8 @@ pub struct HelloReplyShadow<'a> { pub peers: Vec<String>, #[serde(default)] epoch: EpochShadow, + #[serde(default)] + auth: ByteBuf, } #[derive(Serialize, Deserialize)] @@ -849,12 +853,14 @@ mod automerge_msg_codec { pub fn hello_request_to_bytes(msg: &HelloRequest) -> Result<Vec<u8>, rmp_serde::encode::Error> { rmp_serde::to_vec(&HelloRequestShadow { epoch: epoch_to_shadow(&msg.epoch), + auth: ByteBuf::from(msg.auth.clone()), }) } pub fn bytes_to_hello_request(bytes: &[u8]) -> Result<HelloRequest, TransportError> { let shadow: HelloRequestShadow = rmp_serde::from_slice(bytes)?; Ok(HelloRequest { epoch: epoch_from_shadow(shadow.epoch)?, + auth: shadow.auth.into_vec(), }) } @@ -864,6 +870,7 @@ pub fn hello_reply_to_bytes(msg: &HelloReply) -> Result<Vec<u8>, rmp_serde::enco swarm_id: Cow::Borrowed(&msg.swarm_id), peers: msg.peers.clone(), // Vec must be cloned for serialization wrapper matching epoch: epoch_to_shadow(&msg.epoch), + auth: ByteBuf::from(msg.auth.clone()), }; rmp_serde::to_vec(&shadow) } @@ -873,6 +880,7 @@ pub fn bytes_to_hello_reply(bytes: &[u8]) -> Result<HelloReply, TransportError> swarm_id: shadow.swarm_id.into_owned(), peers: shadow.peers, epoch: epoch_from_shadow(shadow.epoch)?, + auth: shadow.auth.into_vec(), }) } |
