Documentation
¶
Index ¶
- func ParseInterface(cfg *ini.File, device *DeviceConfig) error
- func ParsePeerEndpoint(endpoint string) (host netip.Prefix, port uint16, err error)
- func ParsePeers(cfg *ini.File, peers *[]PeerConfig) error
- func TCPAddrFromAddrPort(addr netip.AddrPort) *net.TCPAddr
- func ValidateASecConfig(config *ASecConfigType) error
- type ASecConfigType
- 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 TUNResolver
- type VirtualTun
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 ParsePeerEndpoint ¶
func ParsePeers ¶
func ParsePeers(cfg *ini.File, peers *[]PeerConfig) error
ParsePeers parses the [Peer] section and extract the information into `peers`
func ValidateASecConfig ¶
func ValidateASecConfig(config *ASecConfigType) error
Types ¶
type ASecConfigType ¶
type ASecConfigType struct {
// contains filtered or unexported fields
}
func ParseASecConfig ¶
func ParseASecConfig(section *ini.Section) (*ASecConfigType, error)
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
func ParseConfigString ¶
func ParseConfigString(config string) (*Configuration, error)
ParseConfigString takes the config as a string 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
Address []netip.Addr
Peers []PeerConfig
DNS []netip.Addr
SearchDomains []string
MTU int
ListenPort *int
CheckAlive []netip.Addr
DomainBlockingEnabled bool
BlockedDomains []string
CheckAliveInterval int
ASecConfig *ASecConfigType
}
DeviceConfig contains the information to initiate a wireguard connection
type DeviceSetting ¶
DeviceSetting contains the parameters for setting up a tun interface
func CreateIPCRequest ¶
func CreateIPCRequest(conf *DeviceConfig, isUpdate bool) (*DeviceSetting, error)
CreateIPCRequest serialize the config into an IPC request and DeviceSetting
func CreatePeerIPCRequest ¶
func CreatePeerIPCRequest(conf *DeviceConfig) (*DeviceSetting, error)
CreatePeerIPCRequest builds a UAPI string for updating peers only, based on the provided DeviceConfig.
type HTTPConfig ¶
func (*HTTPConfig) SpawnRoutine ¶
func (config *HTTPConfig) SpawnRoutine(ctx context.Context, vt *VirtualTun) error
SpawnRoutine spawns an http server.
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func (*HTTPServer) ListenAndServe ¶
func (s *HTTPServer) ListenAndServe(ctx context.Context, network, addr string) error
ListenAndServe is used to create a listener and serve on it
type PeerConfig ¶
type PeerConfig struct {
PublicKey string
Endpoint *string
KeepAlive int
AllowedIPs []netip.Prefix
}
func (*PeerConfig) NeedsResolution ¶
func (p *PeerConfig) NeedsResolution() bool
NeedsResolution returns true if the peer's endpoint is a domain name that needs DNS resolution
func (*PeerConfig) UpdateEndpointIP ¶
func (p *PeerConfig) UpdateEndpointIP(resolvedIP netip.Addr) error
UpdateEndpointIP updates the peer's endpoint with the provided resolved IP, preserving the original port.
type RoutineSpawner ¶
type RoutineSpawner interface {
SpawnRoutine(ctx context.Context, vt *VirtualTun) error
}
RoutineSpawner spawns a routine (e.g. socks5, tcp static routes) after the configuration is parsed
type STDIOTunnelConfig ¶
type STDIOTunnelConfig struct {
Target string
}
type Socks5Config ¶
func (*Socks5Config) SpawnRoutine ¶
func (config *Socks5Config) SpawnRoutine(ctx context.Context, vt *VirtualTun) error
SpawnRoutine spawns a socks5 server.
type TCPClientTunnelConfig ¶
type TCPServerTunnelConfig ¶
type TUNResolver ¶
type TUNResolver struct {
// contains filtered or unexported fields
}
TUNResolver forwards DNS resolution through the tunnel
type VirtualTun ¶
type VirtualTun struct {
Tnet *netstack.Net
Dev *device.Device
Logger *device.Logger
Uapi net.Listener
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 (*VirtualTun) ServeHTTP ¶
func (d *VirtualTun) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*VirtualTun) StartPingIPs ¶
func (d *VirtualTun) StartPingIPs()