mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-14 13:22:26 +03:00
Fix federationclient whitelist checks, improve performance
This commit is contained in:
parent
94deed77ec
commit
b5ea31ff5c
2 changed files with 32 additions and 25 deletions
|
@ -112,10 +112,11 @@ func NewFederationInternalAPI(
|
|||
}
|
||||
}
|
||||
|
||||
// IsWhitelistedOrAny checks if the server is whitelisted or the whitelist is disabled, so we can connect to any server
|
||||
// IsWhitelistedOrAny checks if the server is whitelisted or the whitelist is disabled (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
|
||||
// Thread-safe, since DB access is performed in mutex and stats.Whitelisted is constant
|
||||
stats := a.statistics.ForServer(s) // Calls mutex if the stats do not exist yet
|
||||
return !a.cfg.EnableWhitelist || stats.Whitelisted() // Lazy eval
|
||||
}
|
||||
|
||||
func (a *FederationInternalAPI) IsBlacklistedOrBackingOff(s spec.ServerName) (*statistics.ServerStatistics, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue