This commit is contained in:
KdeInit 2025-04-05 17:12:35 -04:00 committed by GitHub
parent 7cc541967e
commit 9a2639f40a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -279,22 +279,25 @@ func (r *RuleActionReject) Error(ctx context.Context) error {
default:
panic(F.ToString("unknown reject method: ", r.Method))
}
r.dropAccess.Lock()
defer r.dropAccess.Unlock()
timeNow := time.Now()
r.dropCounter = common.Filter(r.dropCounter, func(t time.Time) bool {
return timeNow.Sub(t) <= 30*time.Second
})
r.dropCounter = append(r.dropCounter, timeNow)
if len(r.dropCounter) > 50 {
if ctx != nil {
r.logger.DebugContext(ctx, "dropped due to flooding")
if !r.NoDrop {
r.dropAccess.Lock()
defer r.dropAccess.Unlock()
timeNow := time.Now()
r.dropCounter = common.Filter(r.dropCounter, func(t time.Time) bool {
return timeNow.Sub(t) <= 30*time.Second
})
r.dropCounter = append(r.dropCounter, timeNow)
if len(r.dropCounter) > 50 {
if ctx != nil {
r.logger.DebugContext(ctx, "dropped due to flooding")
}
return tun.ErrDrop
}
return tun.ErrDrop
}
return returnErr
}
type RuleActionHijackDNS struct{}
func (r *RuleActionHijackDNS) Type() string {