Documentation
¶
Index ¶
- func ParseInterface(cfg *ini.File, device *DeviceConfig) error
- func ParsePeers(cfg *ini.File, peers *[]PeerConfig) error
- func STDIOTcpForward(vt *VirtualTun, raddr *addressPort)
- func TCPAddrFromAddrPort(addr netip.AddrPort) *net.TCPAddr
- type Configuration
- type CredentialValidator
- type DeviceConfig
- type DeviceSetting
- type HTTPConfig
- type HTTPServer
- type PeerConfig
- type RoutineSpawner
- type STDIOTunnelConfig
- type Socks5Config
- type TCPClientTunnelConfig
- type TCPServerTunnelConfig
- type VirtualTun
- func (d VirtualTun) LookupAddr(ctx context.Context, name string) ([]string, error)
- func (d VirtualTun) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
- func (d VirtualTun) ResolveAddrWithContext(ctx context.Context, name string) (*netip.Addr, error)
- func (d VirtualTun) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (d VirtualTun) StartPingIPs()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseInterface ¶
func ParseInterface(cfg *ini.File, device *DeviceConfig) error
ParseInterface parses the [Interface] section and extract the information into `device`
func ParsePeers ¶
func ParsePeers(cfg *ini.File, peers *[]PeerConfig) error
ParsePeers parses the [Peer] section and extract the information into `peers`
func STDIOTcpForward ¶
func STDIOTcpForward(vt *VirtualTun, raddr *addressPort)
STDIOTcpForward starts a new connection via wireguard and forward traffic from `conn`
Types ¶
type Configuration ¶
type Configuration struct { Device *DeviceConfig Routines []RoutineSpawner }
func ParseConfig ¶
func ParseConfig(path string) (*Configuration, error)
ParseConfig takes the path of a configuration file and parses it into Configuration
type CredentialValidator ¶
type CredentialValidator struct {
// contains filtered or unexported fields
}
CredentialValidator stores the authentication data of a socks5 proxy
func (CredentialValidator) Valid ¶
func (c CredentialValidator) Valid(username, password string) bool
Valid checks the authentication data in CredentialValidator and compare them to username and password in constant time.
type DeviceConfig ¶
type DeviceConfig struct { SecretKey string Endpoint []netip.Addr Peers []PeerConfig DNS []netip.Addr MTU int ListenPort *int CheckAlive []netip.Addr CheckAliveInterval int }
DeviceConfig contains the information to initiate a wireguard connection
type DeviceSetting ¶
DeviceSetting contains the parameters for setting up a tun interface
func CreateIPCRequest ¶ added in v1.0.10
func CreateIPCRequest(conf *DeviceConfig) (*DeviceSetting, error)
CreateIPCRequest serialize the config into an IPC request and DeviceSetting
type HTTPConfig ¶
func (*HTTPConfig) SpawnRoutine ¶
func (config *HTTPConfig) SpawnRoutine(vt *VirtualTun)
SpawnRoutine spawns a http server.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func (*HTTPServer) ListenAndServe ¶
func (s *HTTPServer) ListenAndServe(network, addr string) error
ListenAndServe is used to create a listener and serve on it
type PeerConfig ¶
type RoutineSpawner ¶
type RoutineSpawner interface {
SpawnRoutine(vt *VirtualTun)
}
RoutineSpawner spawns a routine (e.g. socks5, tcp static routes) after the configuration is parsed
type STDIOTunnelConfig ¶
type STDIOTunnelConfig struct {
Target string
}
func (*STDIOTunnelConfig) SpawnRoutine ¶
func (conf *STDIOTunnelConfig) SpawnRoutine(vt *VirtualTun)
SpawnRoutine connects to the specified target and plumbs it to STDIN / STDOUT
type Socks5Config ¶
func (*Socks5Config) SpawnRoutine ¶
func (config *Socks5Config) SpawnRoutine(vt *VirtualTun)
SpawnRoutine spawns a socks5 server.
type TCPClientTunnelConfig ¶
func (*TCPClientTunnelConfig) SpawnRoutine ¶
func (conf *TCPClientTunnelConfig) SpawnRoutine(vt *VirtualTun)
SpawnRoutine spawns a local TCP server which acts as a proxy to the specified target
type TCPServerTunnelConfig ¶
func (*TCPServerTunnelConfig) SpawnRoutine ¶
func (conf *TCPServerTunnelConfig) SpawnRoutine(vt *VirtualTun)
SpawnRoutine spawns a TCP server on wireguard which acts as a proxy to the specified target
type VirtualTun ¶
type VirtualTun struct { Tnet *netstack.Net Dev *device.Device SystemDNS bool Conf *DeviceConfig // PingRecord stores the last time an IP was pinged PingRecord map[string]uint64 PingRecordLock *sync.Mutex }
VirtualTun stores a reference to netstack network and DNS configuration
func StartWireguard ¶
func StartWireguard(conf *DeviceConfig, logLevel int) (*VirtualTun, error)
StartWireguard creates a tun interface on netstack given a configuration
func (VirtualTun) LookupAddr ¶
LookupAddr lookups a hostname. DNS traffic may or may not be routed depending on VirtualTun's setting
func (VirtualTun) Resolve ¶
Resolve resolves a hostname and returns an IP. DNS traffic may or may not be routed depending on VirtualTun's setting
func (VirtualTun) ResolveAddrWithContext ¶
ResolveAddrWithContext resolves a hostname and returns an AddrPort. DNS traffic may or may not be routed depending on VirtualTun's setting
func (VirtualTun) ServeHTTP ¶ added in v1.0.8
func (d VirtualTun) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (VirtualTun) StartPingIPs ¶ added in v1.0.8
func (d VirtualTun) StartPingIPs()