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
- type WireGuardTransport
- type WireProxy
- type Wireguard
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
ParsePeer 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 }
DeviceConfig contains the information to initiate a wireguard connection
type DeviceSetting ¶
type DeviceSetting struct {
// contains filtered or unexported fields
}
DeviceSetting contains the parameters for setting up a tun interface
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 ¶
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
type WireProxy ¶
type WireProxy struct {
// contains filtered or unexported fields
}