Documentation ¶
Index ¶
- Constants
- Variables
- func ActionTypeName(actionType ActionType) (string, error)
- func CalculateInterfaceName(name string) (tunName string)
- func NetworkFromName(name string) uint8
- func NetworkName(network uint8) string
- type ActionBlock
- type ActionDirect
- type ActionReturn
- type ActionType
- type DefaultInterfaceMonitor
- type DefaultInterfaceMonitorOptions
- type DefaultInterfaceUpdateCallback
- type DirectDestination
- type Handler
- type NatMapping
- type NatWriter
- type NativeTun
- type NetworkUpdateCallback
- type NetworkUpdateMonitor
- type Options
- type PackageManager
- type PackageManagerCallback
- type RouteAction
- type RouteContext
- type RouteMapping
- type RouteSession
- type Router
- type Session
- type Stack
- type StackOptions
- type System
- type TCPNat
- type TCPSession
- type Tun
- type WinTun
Constants ¶
View Source
const ( EventInterfaceUpdate = 1 EventAndroidVPNUpdate = 2 )
View Source
const PacketOffset = 0
View Source
const WithGVisor = false
Variables ¶
View Source
var ErrGVisorNotIncluded = E.New(`gVisor is not included in this build, rebuild with -tags with_gvisor`)
View Source
var ErrNoRoute = E.New("no route to internet")
Functions ¶
func ActionTypeName ¶ added in v0.1.3
func ActionTypeName(actionType ActionType) (string, error)
func CalculateInterfaceName ¶
func NetworkFromName ¶ added in v0.1.3
func NetworkName ¶ added in v0.1.3
Types ¶
type ActionBlock ¶ added in v0.1.3
type ActionBlock struct{}
func (*ActionBlock) ActionType ¶ added in v0.1.3
func (r *ActionBlock) ActionType() ActionType
func (*ActionBlock) Timeout ¶ added in v0.1.3
func (r *ActionBlock) Timeout() bool
type ActionDirect ¶ added in v0.1.3
type ActionDirect struct {
DirectDestination
}
func (*ActionDirect) ActionType ¶ added in v0.1.3
func (r *ActionDirect) ActionType() ActionType
type ActionReturn ¶ added in v0.1.3
type ActionReturn struct{}
func (*ActionReturn) ActionType ¶ added in v0.1.3
func (r *ActionReturn) ActionType() ActionType
func (*ActionReturn) Timeout ¶ added in v0.1.3
func (r *ActionReturn) Timeout() bool
type ActionType ¶ added in v0.1.3
type ActionType = uint8
const ( ActionTypeUnknown ActionType = iota ActionTypeReturn ActionTypeBlock ActionTypeDirect )
func ParseActionType ¶ added in v0.1.3
func ParseActionType(action string) (ActionType, error)
type DefaultInterfaceMonitor ¶
type DefaultInterfaceMonitor interface { Start() error Close() error DefaultInterfaceName(destination netip.Addr) string DefaultInterfaceIndex(destination netip.Addr) int OverrideAndroidVPN() bool AndroidVPNEnabled() bool RegisterCallback(callback DefaultInterfaceUpdateCallback) *list.Element[DefaultInterfaceUpdateCallback] UnregisterCallback(element *list.Element[DefaultInterfaceUpdateCallback]) }
func NewDefaultInterfaceMonitor ¶
func NewDefaultInterfaceMonitor(networkMonitor NetworkUpdateMonitor, options DefaultInterfaceMonitorOptions) (DefaultInterfaceMonitor, error)
type DefaultInterfaceMonitorOptions ¶
type DefaultInterfaceMonitorOptions struct {
OverrideAndroidVPN bool
}
type DirectDestination ¶ added in v0.1.3
type Handler ¶
type Handler interface { N.TCPConnectionHandler N.UDPConnectionHandler E.Handler }
type NatMapping ¶ added in v0.1.3
type NatMapping struct {
// contains filtered or unexported fields
}
func NewNatMapping ¶ added in v0.1.3
func NewNatMapping(ipRewrite bool) *NatMapping
func (*NatMapping) CreateSession ¶ added in v0.1.3
func (m *NatMapping) CreateSession(session RouteSession, context RouteContext)
func (*NatMapping) DeleteSession ¶ added in v0.1.3
func (m *NatMapping) DeleteSession(session RouteSession)
func (*NatMapping) WritePacket ¶ added in v0.1.3
func (m *NatMapping) WritePacket(packet []byte) (bool, error)
type NatWriter ¶ added in v0.1.3
type NatWriter struct {
// contains filtered or unexported fields
}
func NewNatWriter ¶ added in v0.1.3
func (*NatWriter) RewritePacket ¶ added in v0.1.3
type NetworkUpdateCallback ¶
type NetworkUpdateCallback = func() error
type NetworkUpdateMonitor ¶
type NetworkUpdateMonitor interface { Start() error Close() error RegisterCallback(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback] UnregisterCallback(element *list.Element[NetworkUpdateCallback]) E.Handler }
func NewNetworkUpdateMonitor ¶
func NewNetworkUpdateMonitor(errorHandler E.Handler) (NetworkUpdateMonitor, error)
type Options ¶
type Options struct { Name string Inet4Address []netip.Prefix Inet6Address []netip.Prefix MTU uint32 AutoRoute bool StrictRoute bool Inet4RouteAddress []netip.Prefix Inet6RouteAddress []netip.Prefix IncludeUID []ranges.Range[uint32] ExcludeUID []ranges.Range[uint32] IncludeAndroidUser []int IncludePackage []string ExcludePackage []string InterfaceMonitor DefaultInterfaceMonitor TableIndex int FileDescriptor int }
func (*Options) BuildAndroidRules ¶
func (o *Options) BuildAndroidRules(packageManager PackageManager, errorHandler E.Handler)
type PackageManager ¶
type PackageManager interface { Start() error Close() error IDByPackage(packageName string) (uint32, bool) PackageByID(id uint32) (string, bool) }
func NewPackageManager ¶
func NewPackageManager(callback PackageManagerCallback) (PackageManager, error)
type PackageManagerCallback ¶
type RouteAction ¶ added in v0.1.3
type RouteAction interface { ActionType() ActionType Timeout() bool }
type RouteContext ¶ added in v0.1.3
type RouteMapping ¶ added in v0.1.3
type RouteMapping struct {
// contains filtered or unexported fields
}
func NewRouteMapping ¶ added in v0.1.3
func NewRouteMapping(maxAge int64) *RouteMapping
func (*RouteMapping) Lookup ¶ added in v0.1.3
func (m *RouteMapping) Lookup(session RouteSession, constructor func() RouteAction) RouteAction
type RouteSession ¶ added in v0.1.3
type Router ¶ added in v0.1.3
type Router interface {
RouteConnection(session RouteSession, context RouteContext) RouteAction
}
type Stack ¶
func NewGVisor ¶
func NewGVisor( options StackOptions, ) (Stack, error)
func NewLWIP ¶
func NewLWIP( options StackOptions, ) (Stack, error)
func NewSystem ¶
func NewSystem(options StackOptions) (Stack, error)
type StackOptions ¶
type StackOptions struct { Context context.Context Tun Tun Name string MTU uint32 Inet4Address []netip.Prefix Inet6Address []netip.Prefix EndpointIndependentNat bool UDPTimeout int64 Router Router Handler Handler Logger logger.Logger ForwarderBindInterface bool InterfaceFinder control.InterfaceFinder }
type TCPNat ¶
type TCPNat struct {
// contains filtered or unexported fields
}
func (*TCPNat) LookupBack ¶
func (n *TCPNat) LookupBack(port uint16) *TCPSession
type TCPSession ¶
type Tun ¶
type Tun interface { io.ReadWriter Close() error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.