sitehttp

package
v0.1.90-dev.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 ConfigureSiteHTTP2

func ConfigureSiteHTTP2(server *http.Server) error

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, and call MarkAuthenticated once the peer has proven itself.

func Conn

func Conn(ctx context.Context) net.Conn

Conn returns the network connection that carries the request whose context is ctx; nil outside a configured server.

func MarkAuthenticated

func MarkAuthenticated(ctx context.Context) net.Conn

MarkAuthenticated takes the connection of a request out of the anonymous set for good (it never returns) and gives it back; calling it again is harmless. It returns nil outside a configured server.

Types

type AnonymousLimiter

type AnonymousLimiter struct {
	// contains filtered or unexported fields
}

AnonymousLimiter bounds connections that have not yet authenticated. Keys must be comparable and stable for the life of a connection. An authenticated key is removed from the set permanently until Remove is called when the connection ends. Add closes evicted connections after releasing 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 removes key from the anonymous set and keeps it out until Remove observes the connection closing.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL