Versions in this module Expand all Collapse all v0 v0.1.2 Dec 21, 2022 Changes in this version + const EventAndroidVPNUpdate + const EventInterfaceUpdate + const IN6_IFF_NODAD — darwin/amd64 + const IN6_IFF_SECURED — darwin/amd64 + const ND6_INFINITE_LIFETIME — darwin/amd64 + const PacketOffset + const SIOCAIFADDR_IN6 — darwin/amd64 + const WithGVisor + var ErrGVisorNotIncluded = E.New(`gVisor is not included in this build, rebuild with -tags with_gvisor`) + var ErrNoRoute = E.New("no route to internet") + var TunnelType = "sing-tun" — windows/amd64 + func CalculateInterfaceName(name string) (tunName string) + func ContextWithNeedTimeout(ctx context.Context, need bool) context.Context + func NeedTimeoutFromContext(ctx context.Context) bool + type DefaultInterfaceMonitor interface + AndroidVPNEnabled func() bool + Close func() error + DefaultInterfaceIndex func(destination netip.Addr) int + DefaultInterfaceName func(destination netip.Addr) string + OverrideAndroidVPN func() bool + RegisterCallback func(callback DefaultInterfaceUpdateCallback) *list.Element[DefaultInterfaceUpdateCallback] + Start func() error + UnregisterCallback func(element *list.Element[DefaultInterfaceUpdateCallback]) + func NewDefaultInterfaceMonitor(networkMonitor NetworkUpdateMonitor, options DefaultInterfaceMonitorOptions) (DefaultInterfaceMonitor, error) + type DefaultInterfaceMonitorOptions struct + OverrideAndroidVPN bool + type DefaultInterfaceUpdateCallback = func(event int) error + type Handler interface + type NativeTun struct — darwin/amd64, linux/amd64, windows/amd64 + func (t *NativeTun) Close() error + func (t *NativeTun) Read(p []byte) (n int, err error) + func (t *NativeTun) ReadFunc(block func(b []byte)) error + func (t *NativeTun) ReadPacket() ([]byte, func(), error) + func (t *NativeTun) Write(p []byte) (n int, err error) + type NetworkUpdateCallback = func() error + type NetworkUpdateMonitor interface + Close func() error + RegisterCallback func(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback] + Start func() error + UnregisterCallback func(element *list.Element[NetworkUpdateCallback]) + func NewNetworkUpdateMonitor(errorHandler E.Handler) (NetworkUpdateMonitor, error) + type Options struct + AutoRoute bool + ExcludePackage []string + ExcludeUID []ranges.Range[uint32] + IncludeAndroidUser []int + IncludePackage []string + IncludeUID []ranges.Range[uint32] + Inet4Address []netip.Prefix + Inet4RouteAddress []netip.Prefix + Inet6Address []netip.Prefix + Inet6RouteAddress []netip.Prefix + InterfaceMonitor DefaultInterfaceMonitor + MTU uint32 + Name string + StrictRoute bool + TableIndex int + func (o *Options) BuildAndroidRules(packageManager PackageManager, errorHandler E.Handler) + func (o *Options) ExcludedRanges() (uidRanges []ranges.Range[uint32]) + type PackageManager interface + Close func() error + IDByPackage func(packageName string) (uint32, bool) + IDBySharedPackage func(sharedPackage string) (uint32, bool) + PackageByID func(id uint32) (string, bool) + SharedPackageByID func(id uint32) (string, bool) + Start func() error + func NewPackageManager(callback PackageManagerCallback) (PackageManager, error) + type PackageManagerCallback interface + OnPackagesUpdated func(packages int, sharedUsers int) + type Session struct + DestinationAddress netip.Addr + DestinationPort uint16 + SourceAddress netip.Addr + SourcePort uint16 + type Stack interface + Close func() error + Start func() error + func NewGVisor(options StackOptions) (Stack, error) + func NewLWIP(options StackOptions) (Stack, error) + func NewStack(stack string, options StackOptions) (Stack, error) + func NewSystem(options StackOptions) (Stack, error) + type StackOptions struct + Context context.Context + EndpointIndependentNat bool + Handler Handler + Inet4Address []netip.Prefix + Inet6Address []netip.Prefix + Logger logger.Logger + MTU uint32 + Name string + Tun Tun + UDPTimeout int64 + type System struct + func (s *System) Close() error + func (s *System) Start() error + type TCPNat struct + func NewNat() *TCPNat + func (n *TCPNat) Lookup(source netip.AddrPort, destination netip.AddrPort) uint16 + func (n *TCPNat) LookupBack(port uint16) *TCPSession + func (n *TCPNat) Revoke(natPort uint16, session *TCPSession) + type TCPSession struct + Destination netip.AddrPort + Source netip.AddrPort + type Tun interface + Close func() error + func Open(config Options) (Tun, error) + func Open(options Options) (Tun, error) + type WinTun interface + ReadPacket func() ([]byte, func(), error) + func Open(options Options) (WinTun, error)