Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-06-08 04:37:18 +03:00
parent 594465269a
commit f7579670cc

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"golang.org/x/time/rate"
"io" "io"
"math/rand" "math/rand"
"mime" "mime"
@@ -11,9 +12,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"sync" "sync"
"golang.org/x/time/rate" "time"
) )
var ( var (
@@ -37,7 +37,7 @@ func getLimiter(ip string) *rate.Limiter {
defer limMu.Unlock() defer limMu.Unlock()
lim, ok := limiters[ip] lim, ok := limiters[ip]
if !ok { if !ok {
lim = rate.NewLimiter(1, 5) // 1 req/sec, burst of 5 lim = rate.NewLimiter(rate.Every(5*time.Second), 1)
limiters[ip] = lim limiters[ip] = lim
} }
return lim return lim