commit
c7fd976ab7
3 changed files with 5 additions and 3 deletions
|
@ -178,7 +178,7 @@ func main() {
|
|||
authCache := cache.New(1*time.Minute, 15*time.Minute)
|
||||
accessTokenCache := cache.New(1*time.Minute, 15*time.Minute)
|
||||
discordController := discord.NewDiscordController(userRepo, hostName, environment)
|
||||
rateLimiter := middleware.NewRateLimitMiddleware(discordController, 5000, 5*time.Second)
|
||||
rateLimiter := middleware.NewRateLimitMiddleware(discordController, 1000, 1*time.Second)
|
||||
defer rateLimiter.Stop()
|
||||
|
||||
emailNotificationCtrl := &email.EmailNotificationController{
|
||||
|
|
|
@ -106,7 +106,7 @@ func (c *DiscordController) NotifyAccountDelete(userID int64, paymentProvider st
|
|||
}
|
||||
|
||||
func (c *DiscordController) NotifyPotentialAbuse(message string) {
|
||||
c.Notify(message)
|
||||
c.Notify(fmt.Sprintf("%s: %s", c.HostName, message))
|
||||
}
|
||||
|
||||
func (c *DiscordController) getTimeSinceSignUp(userID int64) string {
|
||||
|
|
|
@ -76,7 +76,9 @@ func rateLimiter(interval string) *limiter.Limiter {
|
|||
func (r *RateLimitMiddleware) GlobalRateLimiter() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if !r.Increment() {
|
||||
go r.discordCtrl.NotifyPotentialAbuse("Global rate limit breached")
|
||||
if r.count%100 == 0 {
|
||||
go r.discordCtrl.NotifyPotentialAbuse(fmt.Sprintf("Global ratelimit (%d) breached %d", r.limit, r.count))
|
||||
}
|
||||
c.AbortWithStatusJSON(http.StatusTooManyRequests, gin.H{"error": "Rate limit breached, try later"})
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue