Documentation
¶
Overview ¶
Package ratelimit provides a goroutine-safe token-bucket limiter used by the SYN scanner to pace packet emission (--rate flag). TCP-connect mode already self-paces via the socket-concurrency semaphore and does not use this package.
A zero-rate limiter (New(0)) is a no-op — Wait returns immediately — so callers can unconditionally hold a Limiter without conditional branches on a "rate limiting on" flag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adaptive ¶
type Adaptive struct {
// contains filtered or unexported fields
}
Adaptive wraps a token-bucket Limiter with a feedback loop that halves the rate when the probe error-rate crosses a threshold, and doubles it (up to Max) when the error-rate stays well below.
Thresholds are static for v1 per plan §5 (2% high, 0.1% low). The window is fixed at 500 in-flight results.
func NewAdaptive ¶
NewAdaptive returns an Adaptive limiter starting at startRate pps and capping at maxRate. startRate<=0 means unlimited (Adaptive becomes a no-op wrapper). maxRate<=0 defaults to startRate.
func (*Adaptive) ReportProbe ¶
ReportProbe records the outcome of a probe. Pass isErr=true for timeout / unreachable / reset-storm; false for clean open/closed.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is an opaque handle around x/time/rate.Limiter that understands the "zero means unlimited" convention.
func New ¶
New returns a limiter that admits at most rps events per second. burst is the maximum short-term burst; if burst <= 0 it defaults to rps (i.e. roughly one second of traffic). rps <= 0 disables the limiter; Wait is a no-op.