Documentation
¶
Overview ¶
Package wrapper provides net.Conn and net.Listener wrappers that enforce connection limits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConnLimit = errors.New("connection limit exceeded")
ErrConnLimit reports that a connection was refused because it exceeded the connection limit. It is a sentinel so callers can tell a single refused connection apart from a listener that has genuinely failed: the refusal is per-connection and leaves the listener usable, so it must not end an accept loop.
Functions ¶
func WrapConn ¶
WrapConn wraps a net.Conn with a connection limiter. On Close, the limiter's Allow(-1) is called to decrement the current count. If limiter is nil, the original connection is returned unchanged.
func WrapListener ¶
WrapListener wraps a net.Listener with a ConnLimiter. Each accepted connection is checked against the limiter using the remote IP as the key. If the limit is exceeded, the connection is closed with an error. If limiter is nil, the original listener is returned unchanged.
Types ¶
This section is empty.