Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
protocol: Include is_blocked check in `Service::connect`
Fintan Halpenny committed 2 months ago
commit 5133ac0dc8fd0b3aa6ab873bba38c21893c83279
parent cca8af0e73f7838f70fa0b1b9670e6a0b9843f51
1 file changed +5 -0
modified crates/radicle-protocol/src/service.rs
@@ -230,6 +230,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.
@@ -2170,6 +2172,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 });
        }