handshake

package
v3.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.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 handshake bounds concurrent server-side TLS and DTLS handshakes.

Index

Constants

View Source
const (
	// DefaultLimit is the default maximum number of pending handshakes.
	DefaultLimit = 1024
	// DefaultTimeout is the default server-side handshake timeout.
	DefaultTimeout = 30 * time.Second
)

Variables

View Source
var ErrTooManyPending = errors.New("too many pending handshakes")

ErrTooManyPending indicates that a handshake was evicted to admit another.

Functions

This section is empty.

Types

type Attempt

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

Attempt represents one admitted handshake and must be run exactly once.

func (*Attempt) Run

func (a *Attempt) Run(timeout time.Duration) error

Run performs the handshake and releases its slot after failure cleanup. It returns an error when called on a nil attempt.

type Conn

type Conn interface {
	net.Conn
	HandshakeContext(context.Context) error
}

Conn is a connection that performs a context-aware handshake.

type Pending

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

Pending tracks handshakes in admission order.

func NewPending

func NewPending(limit uint32) *Pending

NewPending creates a tracker; a zero limit allows unlimited handshakes.

func (*Pending) Admit

func (p *Pending) Admit(ctx context.Context, conn Conn) *Attempt

Admit registers conn or cancels and closes the oldest attempt. It waits for any slot to be released, and returns nil if ctx is canceled.

Jump to

Keyboard shortcuts

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