Documentation
ΒΆ
Index ΒΆ
- Constants
- func DiscardLogf(format string, args ...any)
- func EncodeBase64ToHex(key string) (string, error)
- func EncodeHexToBase64(key string) (string, error)
- func MustParsePrefixOrAddr(s string) netip.Prefix
- func ParsePrefixOrAddr(s string) (netip.Prefix, error)
- func ParseResolveAddressPort(hostname string, includev6 bool, dnsServer string) (netip.AddrPort, error)
- func RandomIPFromPrefix(cidr netip.Prefix) (netip.Addr, error)
- type Configuration
- type ConnectivityTestOptions
- type InterfaceConfig
- type Logger
- type Option
- func WithConnectivityTest(opts *ConnectivityTestOptions) Option
- func WithContext(ctx context.Context) Option
- func WithLogLevel(loglevel int) Option
- func WithPeer(peer PeerConfig) Option
- func WithPrivateKey(key string) Option
- func WithProxyConfig(opts *ProxyConfig) Option
- func WithWireguardConfig(conf *Configuration) Option
- type PeerConfig
- type ProxyConfig
- type VirtualTun
- func (vt VirtualTun) CheckConnectivity(ctx context.Context, url string, timeout time.Duration) error
- func (vt VirtualTun) LookupAddr(ctx context.Context, name string) ([]string, error)
- func (vt VirtualTun) Resolve(ctx context.Context, name string) (context.Context, net.IP, error)
- func (vt VirtualTun) ResolveAddrWithContext(ctx context.Context, name string) (*netip.Addr, error)
- func (vt VirtualTun) Stop()
- type WireSocks
Constants ΒΆ
const ( LogLevelSilent = iota LogLevelError LogLevelVerbose )
Log levels for use with NewLogger.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func DiscardLogf ΒΆ
DiscardLogf Function for use in Logger for discarding logged lines.
func EncodeBase64ToHex ΒΆ
func EncodeHexToBase64 ΒΆ
func MustParsePrefixOrAddr ΒΆ
MustParsePrefixOrAddr parses s as a netip.Prefix. If that fails, it parses s as a netip.Addr and returns it as a full-prefix. It panics if parsing as an address fails.
func ParsePrefixOrAddr ΒΆ
ParsePrefixOrAddr parses s as a netip.Prefix. If that fails, it parses s as a netip.Addr and returns it as a full-prefix.
Types ΒΆ
type Configuration ΒΆ
type Configuration struct {
Interface *InterfaceConfig
Peers []PeerConfig
}
func ParseConfig ΒΆ
func ParseConfig(path string) (*Configuration, error)
ParseConfig takes the path of a configuration file and parses it into Configuration
func ParseConfigFromText ΒΆ
func ParseConfigFromText(configText string) (*Configuration, error)
ParseConfigFromText takes configuration text directly and parses it into Configuration
func (*Configuration) String ΒΆ
func (c *Configuration) String() (string, error)
type ConnectivityTestOptions ΒΆ
ConnectivityTestOptions holds the configuration for the connectivity test.
type InterfaceConfig ΒΆ
type InterfaceConfig struct {
PrivateKey string
Addresses []netip.Prefix
DNS []netip.Addr
MTU int
FwMark uint32
}
func ParseInterface ΒΆ
func ParseInterface(cfg *ini.File) (InterfaceConfig, error)
ParseInterface parses the [Interface] section
type Logger ΒΆ
type Logger struct {
LogLevel int
Verbosef func(format string, args ...any)
Errorf func(format string, args ...any)
}
A Logger provides logging for a Device. The functions are Printf-style functions. They must be safe for concurrent use. They do not require a trailing newline in the format. If nil, that level of logging will be silent.
type Option ΒΆ
type Option func(*WireSocks)
func WithConnectivityTest ΒΆ
func WithConnectivityTest(opts *ConnectivityTestOptions) Option
func WithContext ΒΆ
func WithLogLevel ΒΆ
func WithPeer ΒΆ
func WithPeer(peer PeerConfig) Option
func WithPrivateKey ΒΆ
func WithProxyConfig ΒΆ
func WithProxyConfig(opts *ProxyConfig) Option
func WithWireguardConfig ΒΆ
func WithWireguardConfig(conf *Configuration) Option
type PeerConfig ΒΆ
func ParsePeers ΒΆ
func ParsePeers(cfg *ini.File) ([]PeerConfig, error)
ParsePeers parses the [Peer] section and extract the information into `peers`
type ProxyConfig ΒΆ
type ProxyConfig struct {
SocksBindAddr *netip.AddrPort
HttpBindAddr *netip.AddrPort
Username string
Password string
}
ProxyConfig holds the configuration for the proxies.
type VirtualTun ΒΆ
type VirtualTun struct {
Tnet *netstack.Net
Dev *device.Device
// contains filtered or unexported fields
}
VirtualTun stores a reference to netstack network
func (VirtualTun) CheckConnectivity ΒΆ
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) Stop ΒΆ
func (vt VirtualTun) Stop()