mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
implement FAIL METADATA RATE_LIMITED
This commit is contained in:
parent
96aa018352
commit
0119bbc36f
8 changed files with 52 additions and 7 deletions
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ergochat/ergo/irc/caps"
|
||||
"github.com/ergochat/ergo/irc/connection_limits"
|
||||
"github.com/ergochat/ergo/irc/languages"
|
||||
"github.com/ergochat/ergo/irc/modes"
|
||||
"github.com/ergochat/ergo/irc/utils"
|
||||
|
|
@ -1039,3 +1040,22 @@ func (client *Client) CountMetadata() int {
|
|||
|
||||
return len(client.metadata)
|
||||
}
|
||||
|
||||
func (client *Client) checkMetadataThrottle() (throttled bool, remainingTime time.Duration) {
|
||||
config := client.server.Config()
|
||||
if !config.Metadata.ClientThrottle.Enabled {
|
||||
return false, 0
|
||||
}
|
||||
|
||||
client.stateMutex.Lock()
|
||||
defer client.stateMutex.Unlock()
|
||||
|
||||
// copy client.metadataThrottle locally and then back for processing
|
||||
var throttle connection_limits.GenericThrottle
|
||||
throttle.ThrottleDetails = client.metadataThrottle
|
||||
throttle.Duration = config.Metadata.ClientThrottle.Duration
|
||||
throttle.Limit = config.Metadata.ClientThrottle.MaxAttempts
|
||||
throttled, remainingTime = throttle.Touch()
|
||||
client.metadataThrottle = throttle.ThrottleDetails
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue