tun

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package tun manages transparent VPN tunnels via tun2proxy-bin subprocess.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComplementCIDRs

func ComplementCIDRs(nets []string) []string

ComplementCIDRs returns the set of CIDRs covering all of IPv4 (and IPv6, if v6 nets are present) except the provided nets. Passed as --bypass args to tun2proxy to implement "route only these CIDRs" semantics.

func QueryRemoteNets

func QueryRemoteNets(client *gossh.Client) []string

QueryRemoteNets SSHes to the host and returns its non-default routes as CIDRs. Mirrors sshuttle's server.py list_routes(): `ip route` (Linux) or `netstat -rn` (macOS/BSD).

func Run

func Run(ctx context.Context, cfg Config) error

Run starts tun2proxy-bin as a subprocess using cfg. Blocks until ctx is cancelled or the process exits. Sends SIGTERM on cancellation so tun2proxy can restore routes before exiting.

Types

type Config

type Config struct {
	SOCKSHost     string
	SOCKSPort     int
	HostName      string   // display name for the exit node(s)
	SSHIPs        []string // SSH peer IPs — auto-bypassed as /32
	ExtraBypasses []string // user --bypass CIDRs
	Nets          []string // --nets: route only these (complement becomes bypasses)
}

Config holds everything Run needs to start tun2proxy.

Jump to

Keyboard shortcuts

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