forward

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 13 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 forward directly forwards WireGuard UDP packets between local and target endpoints.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = errors.New("invalid forward configuration")

ErrInvalidConfig indicates a missing or invalid forwarding endpoint.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listen             netip.AddrPort
	Target             target.Endpoint
	Reserved           wgpacket.Reserved
	Resolver           target.Resolver
	TargetListenConfig net.ListenConfig
	Logger             *slog.Logger
}

Config defines one local listener and upstream WireGuard target.

type Forwarder

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

Forwarder owns one direct bidirectional WireGuard UDP forwarding path.

func Start

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

Start binds the local UDP endpoint and prepares the target asynchronously.

func (*Forwarder) Close

func (f *Forwarder) Close() error

Close stops forwarding and waits for target preparation and both UDP directions to exit.

func (*Forwarder) LocalAddr

func (f *Forwarder) LocalAddr() netip.AddrPort

LocalAddr returns the bound local WireGuard endpoint.

func (*Forwarder) Wait

func (f *Forwarder) Wait() error

Wait blocks until forwarding ends and returns its terminal result.

func (*Forwarder) WaitReady

func (f *Forwarder) WaitReady(ctx context.Context) error

WaitReady waits until the target is resolved and its UDP socket is prepared, or forwarding ends.

Jump to

Keyboard shortcuts

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