chore: build
Backend - Build & Lint / build (push) Successful in 31m59s
Frontend Admin - EAS Build / build (push) Successful in 1h32m56s

This commit is contained in:
Xor290
2026-11-01 13:08:58 +01:00
parent f3eaea4347
commit 0a18460f13
20 changed files with 1694 additions and 190 deletions
+17 -1
View File
@@ -7,6 +7,7 @@ import (
"net/http"
"strconv"
"strings"
"sync"
"time"
"github.com/gin-gonic/gin"
@@ -14,11 +15,26 @@ import (
var (
cancelRateLimitMap = make(map[string][]time.Time)
cancelRateLimitMu sync.Mutex
cancelMaxRequests = 5 // Max 5 annulations
cancelTimeWindow = time.Hour // Par heure
)
func isCancelRateLimited(key string) bool {
cancelRateLimitMu.Lock()
defer cancelRateLimitMu.Unlock()
return countRecent(cancelRateLimitMap[key], cancelTimeWindow) >= cancelMaxRequests
}
func resetCancelRateLimit(key string) {
cancelRateLimitMu.Lock()
defer cancelRateLimitMu.Unlock()
delete(cancelRateLimitMap, key)
}
func checkCancelRateLimit(key string) bool {
cancelRateLimitMu.Lock()
defer cancelRateLimitMu.Unlock()
now := time.Now()
if timestamps, exists := cancelRateLimitMap[key]; exists {
@@ -67,7 +83,7 @@ func CancelCommandByClient(c *gin.Context) {
return
}
rateLimitKey := fmt.Sprintf("cancel:%s", username)
rateLimitKey := cancelRateLimitKey(username)
if !checkCancelRateLimit(rateLimitKey) {
log.Printf("⚠️ [CANCEL_CLIENT] Rate limit dépassé pour %s", username)
c.JSON(http.StatusTooManyRequests, gin.H{