feat: added basic ACL functionality

This commit is contained in:
NinekoTheCat 2023-12-24 11:03:02 +01:00
parent 6a9f8dfa6f
commit 7562925aeb
No known key found for this signature in database
GPG key ID: 700DB3F678A4AB66
13 changed files with 183 additions and 4 deletions

View file

@ -99,7 +99,7 @@ impl FedDest {
}
}
fn hostname(&self) -> String {
pub(crate) fn hostname(&self) -> String {
match &self {
Self::Literal(addr) => addr.ip().to_string(),
Self::Named(host, _) => host.clone(),
@ -154,6 +154,14 @@ where
(result.0, result.1.into_uri_string())
};
debug!("Checking acl allowance for {}", destination);
if !services().acl.is_federation_with_allowed_fedi_dest(&actual_destination) {
debug!("blocked sending federation to {:?}", actual_destination);
return Err(Error::ACLBlock(destination.to_owned()));
}
let actual_destination_str = actual_destination.clone().into_https_string();
let mut http_request = request