relay

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package relay implements the bidirectional TCP proxy that sits between a local VPN client and the upstream (cloaked) server.

The relay is platform-agnostic: once the DPI bypass (packet injection) has succeeded for a flow, the relay simply shuttles bytes in both directions. Zero-copy fast paths (splice on Linux, TransmitFile on Windows) are added in the platform packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, client, remote net.Conn, opt Options) error

Run copies bytes between client and remote until either side closes or ctx is cancelled. Both conns are closed on return. It returns the first non-EOF error encountered, or nil on normal close.

Types

type Listener

type Listener struct {
	net.Listener
	KeepAlive time.Duration
}

Listener is a thin wrapper that applies relay-friendly TCP socket options. Individual platform backends may replace it with one that also installs packet-filter rules, but the defaults here work anywhere Go runs.

func NewListener

func NewListener(addr string, keepAlive time.Duration) (*Listener, error)

NewListener binds addr and returns a *Listener with TCP keepalive preset.

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept returns the next inbound conn with KeepAlive configured.

type Options

type Options struct {
	// IdleTimeout aborts a relay if no data moves in either direction for
	// this long. Zero means no timeout.
	IdleTimeout time.Duration
	// OnBytes, if set, is called periodically with (txToRemote, rxFromRemote)
	// cumulative byte counts for metrics.
	OnBytes func(tx, rx uint64)
}

Options configures relay behaviour.

Jump to

Keyboard shortcuts

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