feat(rust): change `AllowDestinationAddress` access control logic
@@ -57,6 +57,7 @@ use crate::Address;
/// An Access Control type that allows messages from the given source address to go through
#[derive(Debug)]
+// FIXME: @ac rename
pub struct AllowSourceAddress(pub Address);
#[async_trait]
@@ -72,15 +73,21 @@ impl AccessControl for AllowSourceAddress {
/// An Access Control type that allows messages to the given destination address to go through
#[derive(Debug)]
+// FIXME: @ac rename
pub struct AllowDestinationAddress(pub Address);
#[async_trait]
impl AccessControl for AllowDestinationAddress {
async fn is_authorized(&self, relay_msg: &RelayMessage) -> Result<bool> {
- if relay_msg.destination == self.0 {
+ let onward_route = &relay_msg.onward;
+
+ // Check if next hop is equal to expected value. Further hops are not checked
+ if onward_route.next()? != &self.0 {
+ return crate::deny();
+ }
+
crate::allow()
- } else {
- crate::deny()
+ }
}
}
}
