Documentation
¶
Overview ¶
Package datagram owns WireGuard-facing UDP endpoint behavior.
Index ¶
- Constants
- Variables
- func ReadBatch(ctx context.Context, endpoint Endpoint, packets []Packet) (int, error)
- func WriteBatch(ctx context.Context, endpoint Endpoint, payloads [][]byte, deadline time.Time) (int, error)
- type Endpoint
- type Local
- func (e *Local) Close() error
- func (e *Local) LocalAddr() netip.AddrPort
- func (e *Local) Read(ctx context.Context) (Packet, error)
- func (e *Local) ReadBatch(ctx context.Context, packets []Packet) (int, error)
- func (e *Local) Write(ctx context.Context, payload []byte, deadline time.Time) error
- func (e *Local) WriteBatch(ctx context.Context, payloads [][]byte, deadline time.Time) (int, error)
- type Packet
- type Remote
- func (e *Remote) Close() error
- func (e *Remote) Read(ctx context.Context) (Packet, error)
- func (e *Remote) ReadBatch(ctx context.Context, packets []Packet) (int, error)
- func (e *Remote) Write(ctx context.Context, payload []byte, deadline time.Time) error
- func (e *Remote) WriteBatch(ctx context.Context, payloads [][]byte, deadline time.Time) (int, error)
- type RemoteConfig
Constants ¶
const (
// MaximumBatchSize bounds opportunistic packet vectors throughout the relay data path.
MaximumBatchSize = 16
)
Variables ¶
var ( // ErrNoLocalPeer indicates that no WireGuard process has sent a local datagram yet. ErrNoLocalPeer = errors.New("no local UDP peer") // ErrDatagramDropped indicates a per-datagram rejection or failure that does not invalidate the UDP endpoint. ErrDatagramDropped = errors.New("UDP datagram dropped") )
Functions ¶
Types ¶
type Endpoint ¶
type Endpoint interface {
// Read returns one accepted packet with a caller-owned payload. Read calls on the same endpoint must not overlap.
Read(context.Context) (Packet, error)
// Write synchronously delivers one accepted WireGuard packet before deadline, or only the context deadline when
// deadline is zero. It must not retain payload after returning.
Write(context.Context, []byte, time.Time) error
Close() error
}
Endpoint reads and writes one side of a WireGuard UDP data path.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a UDP listener that tracks the latest valid local WireGuard source.
func ListenLocal ¶
ListenLocal binds a local WireGuard UDP listener.
func (*Local) Read ¶
Read returns the next structurally valid local WireGuard datagram and remembers its source.
func (*Local) ReadBatch ¶ added in v0.2.0
ReadBatch returns one blocking packet plus currently queued valid local WireGuard datagrams.
type Packet ¶
Packet is one accepted WireGuard-looking UDP datagram.
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote is an upstream logical target with DNS candidates and WireGuard index affinity.
func OpenRemote ¶
func OpenRemote(parent context.Context, endpoint target.Endpoint, config RemoteConfig) (*Remote, error)
OpenRemote resolves target and opens its per-family UDP sockets. The context bounds preparation only. The caller must close a successful result to stop its readers and DNS refreshes.
func (*Remote) Read ¶
Read returns the next structurally valid WireGuard datagram from an accepted target candidate.
func (*Remote) ReadBatch ¶ added in v0.2.0
ReadBatch returns an accepted target packet vector from either address family.
type RemoteConfig ¶ added in v0.2.0
type RemoteConfig struct {
Resolver target.Resolver
ListenConfig net.ListenConfig
Logger *slog.Logger
}
RemoteConfig defines target resolution and upstream UDP socket creation.