Implement server whitelist

This commit is contained in:
enaix 2025-01-16 12:31:37 +03:00
parent add73ec866
commit b2ecd5648c
14 changed files with 332 additions and 0 deletions

View file

@ -112,6 +112,12 @@ func NewFederationInternalAPI(
}
}
// IsWhitelistedOrAny checks if the server is whitelisted or the whitelist is disabled, so we can connect to any server
func (a *FederationInternalAPI) IsWhitelistedOrAny(s spec.ServerName) bool {
stats := a.statistics.ForServer(s)
return stats.Whitelisted() || !a.cfg.EnableWhitelist
}
func (a *FederationInternalAPI) IsBlacklistedOrBackingOff(s spec.ServerName) (*statistics.ServerStatistics, error) {
stats := a.statistics.ForServer(s)
if stats.Blacklisted() {