sleep on global limiter

This commit is contained in:
Maycon Santos
2025-05-08 10:45:56 +02:00
parent 86fa1eaa16
commit 3e963ffeba

View File

@@ -458,6 +458,8 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
if !ok {
// Check global limiter before allowing a new peer limiter
if !s.loginLimiter.Allow() {
time.Sleep(time.Second + (time.Millisecond * time.Duration(rand.IntN(20)*100)))
log.WithContext(ctx).Warnf("rate limit exceeded for peer %s", req.WgPubKey)
return nil, fmt.Errorf("temp rate limit reached (global limit)")
}