tun

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogEnabled

func SetLogEnabled(enabled bool)

Types

type DNSConfig

type DNSConfig struct {
	FakeDNS      bool   `json:"fake_dns"`
	FakeDNSRange string `json:"fake_dns_range"`
}

DNSConfig defines DNS behavior.

type InboundConfig

type InboundConfig struct {
	TunName      string `json:"tun_name"`
	Inet4Address string `json:"inet4_address"`
	MTU          uint32 `json:"mtu"`
	AutoRoute    bool   `json:"auto_route"`
	StrictRoute  bool   `json:"strict_route"`
	Sniff        bool   `json:"sniff"`
}

InboundConfig defines the TUN device settings.

type OutboundConfig

type OutboundConfig struct {
	Tag      string `json:"tag"`
	Type     string `json:"type"`
	Server   string `json:"server,omitempty"`
	Port     uint16 `json:"port,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

OutboundConfig defines an outbound (direct / http / socks5).

type RouteConfig

type RouteConfig struct {
	Rules            []RuleConfig `json:"rules"`
	Final            string       `json:"final"`
	DefaultInterface string       `json:"default_interface,omitempty"`
}

RouteConfig holds routing rules and default outbound.

type RuleConfig

type RuleConfig struct {
	ProcessName  []string `json:"process_name,omitempty"`
	DomainSuffix []string `json:"domain_suffix,omitempty"`
	Domain       []string `json:"domain,omitempty"`
	IPCidr       []string `json:"ip_cidr,omitempty"`
	Port         []uint16 `json:"port,omitempty"`
	Protocol     string   `json:"protocol,omitempty"`
	Invert       bool     `json:"invert,omitempty"`
	Outbound     string   `json:"outbound"`
}

RuleConfig defines a single routing rule.

type Server

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

Server manages the TUN device lifecycle and traffic routing.

func New

func New(cfg *TunConfig) (*Server, error)

New creates a new TUN Server from config. Does NOT start the TUN device yet.

func (*Server) Close

func (s *Server) Close() error

Close stops the TUN device and cleans up resources.

func (*Server) Start

func (s *Server) Start() error

Start creates the TUN device, stack, and begins processing traffic.

type TunConfig

type TunConfig struct {
	Enabled   bool             `json:"enabled"`
	Inbound   InboundConfig    `json:"inbound"`
	Outbounds []OutboundConfig `json:"outbounds"`
	Route     RouteConfig      `json:"route"`
	DNS       DNSConfig        `json:"dns"`
}

TunConfig is the top-level configuration for the TUN forwarder.

func DefaultConfig

func DefaultConfig() *TunConfig

func LoadConfig

func LoadConfig(path string) (*TunConfig, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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