Documentation
¶
Overview ¶
Package sitehttp holds the HTTP/2 settings and the anonymous-connection limit shared by HTTPS listeners. The settings are part of what a scanner can measure, so all HTTP/2 sites must answer alike: change them here, never in one caller. The reusable limiter applies the same source grouping and eviction rule to TCP and QUIC connections.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireAuthenticated ¶
AcquireAuthenticated protects the request's connection until the matching ReleaseAuthenticated. It refuses connections already evicted or over the authenticated budget. Without a configured server it is a no-op.
func ConfigureSiteHTTP2 ¶
ConfigureSiteHTTP2 keeps the standard Go HTTP/2 settings and raises only connection receive credit. It also bounds the anonymous connections of the site: past the limit the oldest connection of the busiest source is closed to make room, so a new connection (a client's, for one) is always taken in and a flood only evicts itself first.
It must run before the server serves. Handlers reach the connection of a request with Conn.
func Conn ¶
Conn returns the network connection that carries the request whose context is ctx; nil outside a configured server.
func MarkAuthenticated ¶
MarkAuthenticated protects the connection for its lifetime if the authenticated budget has room. It returns the connection (nil outside a configured server).
func ReleaseAuthenticated ¶
ReleaseAuthenticated releases one successful AcquireAuthenticated. A connection with no protection returns to the anonymous budget.
Types ¶
type AnonymousLimiter ¶
type AnonymousLimiter struct {
// contains filtered or unexported fields
}
AnonymousLimiter bounds both anonymous and protected connections. Keys must be comparable and stable for the life of a connection. Evicted connections are closed outside the limiter lock.
func NewAnonymousLimiter ¶
func NewAnonymousLimiter() *AnonymousLimiter
NewAnonymousLimiter creates an empty limiter with the site-wide limits and eviction order.
func (*AnonymousLimiter) Add ¶
func (l *AnonymousLimiter) Add(key any, addr net.Addr, closeConn func())
Add records a new anonymous connection. It closes the oldest connection of the busiest source when the total limit is full, and closes a source's oldest connection when that source exceeds its own limit.
func (*AnonymousLimiter) Crowded ¶
func (l *AnonymousLimiter) Crowded() bool
Crowded reports that the anonymous set is at least half full: the site is being scanned or flooded.
func (*AnonymousLimiter) MarkAuthenticated ¶
func (l *AnonymousLimiter) MarkAuthenticated(key any)
MarkAuthenticated protects key until Remove observes the connection closing, if the authenticated budget has room.
func (*AnonymousLimiter) Remove ¶
func (l *AnonymousLimiter) Remove(key any)
Remove forgets a connection after it closes.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sitehttptest checks that an HTTPS site of the node speaks HTTP/2 like every other one.
|
Package sitehttptest checks that an HTTPS site of the node speaks HTTP/2 like every other one. |