mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-12 14:40:37 +08:00
node: Implement signed refs
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -7,6 +7,7 @@ use crate::crypto;
|
||||
use crate::identity::{ProjId, UserId};
|
||||
use crate::protocol::{Context, NodeId, Timestamp, PROTOCOL_VERSION};
|
||||
use crate::storage;
|
||||
use crate::storage::refs::SignedRefs;
|
||||
|
||||
/// Message envelope. All messages sent over the network are wrapped in this type.
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -104,9 +105,7 @@ pub enum Message {
|
||||
/// User signing.
|
||||
user: UserId,
|
||||
/// Updated refs.
|
||||
refs: storage::Refs,
|
||||
/// Signature over the refs.
|
||||
signature: crypto::Signature,
|
||||
refs: SignedRefs<crypto::Unverified>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -194,18 +194,8 @@ impl Peer {
|
||||
}));
|
||||
}
|
||||
}
|
||||
(
|
||||
PeerState::Negotiated { git, .. },
|
||||
Message::RefsUpdate {
|
||||
proj,
|
||||
user,
|
||||
refs,
|
||||
signature,
|
||||
},
|
||||
) => {
|
||||
let bytes = serde_json::to_vec(&refs).unwrap();
|
||||
|
||||
if user.verify(&signature, &bytes).is_ok() {
|
||||
(PeerState::Negotiated { git, .. }, Message::RefsUpdate { proj, user, refs }) => {
|
||||
if refs.verified(&user).is_ok() {
|
||||
// TODO: Buffer/throttle fetches.
|
||||
// TODO: Also pass the updated refs so that we can check whether
|
||||
// we need to fetch or not.
|
||||
|
||||
Reference in New Issue
Block a user