client

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 32 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 client implements WireHop client startup and session ownership.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidConfig indicates missing address, authentication, timing, or queue configuration.
	ErrInvalidConfig = errors.New("invalid client configuration")
	// ErrUnexpectedServerResponse indicates a valid but contextually impossible handshake response.
	ErrUnexpectedServerResponse = errors.New("unexpected server response")
	// ErrSessionGone indicates that the server no longer retains a session being joined.
	ErrSessionGone = errors.New("relay session is gone")
	// ErrSessionAttemptTimeout indicates that one lane's session creation attempt exhausted its operation budget.
	ErrSessionAttemptTimeout = errors.New("relay session creation timed out")
	// ErrLaneRejected indicates a permanent carrier-specific admission rejection.
	ErrLaneRejected = errors.New("relay lane rejected")
)

Functions

This section is empty.

Types

type Client

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

Client owns the early-bound local UDP socket and asynchronous relay session.

func Start

func Start(parent context.Context, config Config) (*Client, error)

Start validates config, binds UDP immediately, and starts carrier session establishment.

func (*Client) Close

func (c *Client) Close() error

Close stops the client and closes its local UDP listener.

func (*Client) LocalAddr

func (c *Client) LocalAddr() netip.AddrPort

LocalAddr returns the already-bound local WireGuard endpoint.

func (*Client) SessionID

func (c *Client) SessionID() protocol.SessionID

SessionID returns the created session identifier or zero before successful admission.

func (*Client) Wait

func (c *Client) Wait() error

Wait blocks until the relay session ends and returns its terminal result.

type Config

type Config struct {
	Lanes                 []lanespec.Spec
	Listen                netip.AddrPort
	Target                target.Endpoint
	Reserved              wgpacket.Reserved
	Token                 []byte
	Clock                 relay.Clock
	WallClock             func() time.Time
	Dialer                *net.Dialer
	Proxy                 func(*http.Request) (*neturl.URL, error)
	TLSConfig             *tls.Config
	Logger                *slog.Logger
	HandshakeTimeout      time.Duration
	SessionAttemptTimeout time.Duration
	MaxLanes              int
	IngressLimits         packetqueue.Limits
	LaneLimits            packetqueue.Limits
	Deadlines             relay.DeadlinePolicy
	DeduplicationWindow   int
}

Config defines the carrier lanes and local WireGuard listener for one relay session.

type RejectionError

type RejectionError struct {
	Code       protocol.ErrorCode
	Class      protocol.ErrorClass
	Scope      protocol.ErrorScope
	Diagnostic string
}

RejectionError is an authenticated server rejection.

func (*RejectionError) Error

func (e *RejectionError) Error() string

Error returns stable rejection metadata without exposing the peer's diagnostic text.

Jump to

Keyboard shortcuts

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