Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: include is_blocked check in `Service::connect`
Fintan Halpenny committed 2 months ago
commit 7970b2b69a4373353096907b365e2e3bbbbd12ae
parent 5eb272ce08627317eee697ae79b241a4f6518fa2
1 file changed +5 -0
modified crates/radicle-protocol/src/service.rs
@@ -229,6 +229,8 @@ pub enum ConnectError {
        "attempted connection to {nid}, via {addr} but addresses of this kind are not supported"
    )]
    UnsupportedAddress { nid: NodeId, addr: Address },
+
    #[error("attempted connection with blocked peer {nid}")]
+
    Blocked { nid: NodeId },
}

/// A store for all node data.
@@ -2217,6 +2219,9 @@ where
        if nid == self.node_id() {
            return Err(ConnectError::SelfConnection);
        }
+
        if let Ok(true) = self.policies.is_blocked(&nid) {
+
            return Err(ConnectError::Blocked { nid });
+
        }
        if !self.is_supported_address(&addr) {
            return Err(ConnectError::UnsupportedAddress { nid, addr });
        }