client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 31 Imported by: 0

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")
	// ErrStartupTimeout indicates that no configured lane created a session within the startup budget.
	ErrStartupTimeout = errors.New("relay session startup 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
	StartupTimeout      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 the stable rejection diagnostic.

Jump to

Keyboard shortcuts

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