Documentation
¶
Index ¶
- Variables
- func IsFinalAction(action RuleAction) bool
- func LegacyStart(starter any, stage StartStage) error
- func OutboundTag(detour Outbound) string
- func OverrideContext(ctx context.Context) context.Context
- func RootPoolFromContext(ctx context.Context) *x509.CertPool
- func Start(stage StartStage, services ...Lifecycle) error
- func StartNamed(stage StartStage, services []LifecycleService) error
- func UpstreamMetadata(metadata InboundContext) M.Metadatadeprecated
- func WithContext(ctx context.Context, inboundContext *InboundContext) context.Context
- type CacheFile
- type CertificateStore
- type ClashServer
- type ConnectionHandler
- type ConnectionHandlerEx
- type ConnectionHandlerFunc
- type ConnectionHandlerFuncEx
- type ConnectionManager
- type ConnectionRouterdeprecated
- type ConnectionRouterEx
- type ConnectionTracker
- type DNSClient
- type DNSQueryOptions
- type DNSRouter
- type DNSRule
- type DNSTransport
- type DNSTransportManager
- type DNSTransportRegistry
- type Endpoint
- type EndpointManager
- type EndpointRegistry
- type FakeIPMetadata
- type FakeIPStorage
- type FakeIPStore
- type FakeIPTransport
- type HTTPStartContext
- type HeadlessRule
- type Inbound
- type InboundContext
- type InboundManager
- type InboundRegistry
- type InterfaceUpdateListener
- type LegacyDNSTransport
- type Lifecycle
- type LifecycleService
- type ManagedSSMServer
- type NetworkInterface
- type NetworkManager
- type NetworkOptions
- type OOBPacketHandlerdeprecated
- type OOBPacketHandlerEx
- type Outbound
- type OutboundGroup
- type OutboundManager
- type OutboundRegistry
- type PacketConnectionHandler
- type PacketConnectionHandlerEx
- type PacketConnectionHandlerFunc
- type PacketConnectionHandlerFuncEx
- type PacketHandlerdeprecated
- type PacketHandlerEx
- type RDRCStore
- type Router
- type Rule
- type RuleAction
- type RuleSet
- type RuleSetMetadata
- type RuleSetUpdateCallback
- type SSMTracker
- type SavedBinary
- type Service
- type ServiceManager
- type ServiceRegistry
- type SimpleLifecycle
- type StartStage
- type TCPInjectableInbound
- type TimeService
- type UDPInjectableInbound
- type URLTestGroup
- type URLTestHistory
- type URLTestHistoryStorage
- type UpstreamHandlerAdapterdeprecated
- func NewRouteContextHandler(router ConnectionRouter, logger logger.ContextLogger) UpstreamHandlerAdapterdeprecated
- func NewRouteHandler(metadata InboundContext, router ConnectionRouter, logger logger.ContextLogger) UpstreamHandlerAdapterdeprecated
- func NewUpstreamContextHandler(connectionHandler ConnectionHandlerFunc, ...) UpstreamHandlerAdapterdeprecated
- func NewUpstreamHandler(metadata InboundContext, connectionHandler ConnectionHandlerFunc, ...) UpstreamHandlerAdapter
- type UpstreamHandlerAdapterEx
- func NewRouteContextHandlerEx(router ConnectionRouterEx) UpstreamHandlerAdapterEx
- func NewRouteHandlerEx(metadata InboundContext, router ConnectionRouterEx) UpstreamHandlerAdapterEx
- func NewUpstreamContextHandlerEx(connectionHandler ConnectionHandlerFuncEx, ...) UpstreamHandlerAdapterEx
- func NewUpstreamHandlerEx(metadata InboundContext, connectionHandler ConnectionHandlerFuncEx, ...) UpstreamHandlerAdapterEx
- type V2RayClientTransport
- type V2RayServer
- type V2RayServerTransport
- type V2RayServerTransportHandler
- type WIFIState
Constants ¶
This section is empty.
Variables ¶
View Source
var ListStartStages = []StartStage{ StartStateInitialize, StartStateStart, StartStatePostStart, StartStateStarted, }
Functions ¶
func IsFinalAction ¶ added in v1.12.4
func IsFinalAction(action RuleAction) bool
func LegacyStart ¶ added in v1.12.4
func LegacyStart(starter any, stage StartStage) error
func OutboundTag ¶
func RootPoolFromContext ¶ added in v1.12.4
func Start ¶ added in v1.12.4
func Start(stage StartStage, services ...Lifecycle) error
func StartNamed ¶ added in v1.12.4
func StartNamed(stage StartStage, services []LifecycleService) error
func UpstreamMetadata
deprecated
func UpstreamMetadata(metadata InboundContext) M.Metadata
Deprecated: removed
func WithContext ¶
func WithContext(ctx context.Context, inboundContext *InboundContext) context.Context
Types ¶
type CacheFile ¶
type CacheFile interface {
LifecycleService
StoreFakeIP() bool
FakeIPStorage
StoreRDRC() bool
RDRCStore
LoadMode() string
StoreMode(mode string) error
LoadSelected(group string) string
StoreSelected(group string, selected string) error
LoadGroupExpand(group string) (isExpand bool, loaded bool)
StoreGroupExpand(group string, expand bool) error
LoadRuleSet(tag string) *SavedBinary
SaveRuleSet(tag string, set *SavedBinary) error
}
type CertificateStore ¶ added in v1.12.4
type CertificateStore interface {
LifecycleService
Pool() *x509.CertPool
}
type ClashServer ¶
type ClashServer interface {
LifecycleService
ConnectionTracker
Mode() string
ModeList() []string
HistoryStorage() URLTestHistoryStorage
}
type ConnectionHandler ¶
type ConnectionHandler interface {
NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
}
Deprecated
type ConnectionHandlerEx ¶ added in v1.12.4
type ConnectionHandlerEx interface {
NewConnectionEx(ctx context.Context, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
type ConnectionHandlerFunc ¶
type ConnectionHandlerFunc = func(ctx context.Context, conn net.Conn, metadata InboundContext) error
Deprecated
type ConnectionHandlerFuncEx ¶ added in v1.12.4
type ConnectionHandlerFuncEx = func(ctx context.Context, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
type ConnectionManager ¶ added in v1.12.4
type ConnectionManager interface {
Lifecycle
NewConnection(ctx context.Context, this N.Dialer, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
NewPacketConnection(ctx context.Context, this N.Dialer, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
type ConnectionRouter
deprecated
type ConnectionRouter interface {
RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error
RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}
Deprecated: Use ConnectionRouterEx instead.
type ConnectionRouterEx ¶ added in v1.12.4
type ConnectionRouterEx interface {
ConnectionRouter
RouteConnectionEx(ctx context.Context, conn net.Conn, metadata InboundContext, onClose N.CloseHandlerFunc)
RoutePacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
type ConnectionTracker ¶ added in v1.12.4
type ConnectionTracker interface {
RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule, matchOutbound Outbound) net.Conn
RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule, matchOutbound Outbound) N.PacketConn
}
type DNSClient ¶ added in v1.12.4
type DNSClient interface {
Start()
Exchange(ctx context.Context, transport DNSTransport, message *dns.Msg, options DNSQueryOptions, responseChecker func(responseAddrs []netip.Addr) bool) (*dns.Msg, error)
Lookup(ctx context.Context, transport DNSTransport, domain string, options DNSQueryOptions, responseChecker func(responseAddrs []netip.Addr) bool) ([]netip.Addr, error)
LookupCache(domain string, strategy C.DomainStrategy) ([]netip.Addr, bool)
ExchangeCache(ctx context.Context, message *dns.Msg) (*dns.Msg, bool)
ClearCache()
}
type DNSQueryOptions ¶ added in v1.12.4
type DNSQueryOptions struct {
Transport DNSTransport
Strategy C.DomainStrategy
LookupStrategy C.DomainStrategy
DisableCache bool
RewriteTTL *uint32
ClientSubnet netip.Prefix
}
func DNSQueryOptionsFrom ¶ added in v1.12.4
func DNSQueryOptionsFrom(ctx context.Context, options *option.DomainResolveOptions) (*DNSQueryOptions, error)
type DNSRule ¶
type DNSRule interface {
Rule
WithAddressLimit() bool
MatchAddressLimit(metadata *InboundContext) bool
}
type DNSTransport ¶ added in v1.12.4
type DNSTransportManager ¶ added in v1.12.4
type DNSTransportManager interface {
Lifecycle
Transports() []DNSTransport
Transport(tag string) (DNSTransport, bool)
Default() DNSTransport
FakeIP() FakeIPTransport
Remove(tag string) error
Create(ctx context.Context, logger log.ContextLogger, tag string, outboundType string, options any) error
}
type DNSTransportRegistry ¶ added in v1.12.4
type DNSTransportRegistry interface {
option.DNSTransportOptionsRegistry
CreateDNSTransport(ctx context.Context, logger log.ContextLogger, tag string, transportType string, options any) (DNSTransport, error)
}
type EndpointManager ¶ added in v1.12.4
type EndpointRegistry ¶ added in v1.12.4
type FakeIPMetadata ¶
type FakeIPMetadata struct {
Inet4Range netip.Prefix
Inet6Range netip.Prefix
Inet4Current netip.Addr
Inet6Current netip.Addr
}
func (*FakeIPMetadata) MarshalBinary ¶
func (m *FakeIPMetadata) MarshalBinary() (data []byte, err error)
func (*FakeIPMetadata) UnmarshalBinary ¶
func (m *FakeIPMetadata) UnmarshalBinary(data []byte) error
type FakeIPStorage ¶
type FakeIPStorage interface {
FakeIPMetadata() *FakeIPMetadata
FakeIPSaveMetadata(metadata *FakeIPMetadata) error
FakeIPSaveMetadataAsync(metadata *FakeIPMetadata)
FakeIPStore(address netip.Addr, domain string) error
FakeIPStoreAsync(address netip.Addr, domain string, logger logger.Logger)
FakeIPLoad(address netip.Addr) (string, bool)
FakeIPLoadDomain(domain string, isIPv6 bool) (netip.Addr, bool)
FakeIPReset() error
}
type FakeIPStore ¶
type FakeIPTransport ¶
type FakeIPTransport interface {
DNSTransport
Store() FakeIPStore
}
type HTTPStartContext ¶
type HTTPStartContext struct {
// contains filtered or unexported fields
}
func NewHTTPStartContext ¶
func NewHTTPStartContext(ctx context.Context) *HTTPStartContext
func (*HTTPStartContext) Close ¶
func (c *HTTPStartContext) Close()
func (*HTTPStartContext) HTTPClient ¶
type HeadlessRule ¶
type HeadlessRule interface {
Match(metadata *InboundContext) bool
String() string
}
type InboundContext ¶
type InboundContext struct {
Inbound string
InboundType string
IPVersion uint8
Network string
Source M.Socksaddr
Destination M.Socksaddr
User string
Outbound string
Protocol string
Domain string
Client string
SniffContext any
SniffError error
// Deprecated: implement in rule action
InboundDetour string
LastInbound string
OriginDestination M.Socksaddr
RouteOriginalDestination M.Socksaddr
// Deprecated: to be removed
//nolint:staticcheck
InboundOptions option.InboundOptions
UDPDisableDomainUnmapping bool
UDPConnect bool
UDPTimeout time.Duration
TLSFragment bool
TLSFragmentFallbackDelay time.Duration
TLSRecordFragment bool
NetworkStrategy *C.NetworkStrategy
NetworkType []C.InterfaceType
FallbackNetworkType []C.InterfaceType
FallbackDelay time.Duration
DestinationAddresses []netip.Addr
SourceGeoIPCode string
GeoIPCode string
ProcessInfo *process.Info
QueryType uint16
FakeIP bool
IPCIDRMatchSource bool
IPCIDRAcceptEmpty bool
SourceAddressMatch bool
SourcePortMatch bool
DestinationAddressMatch bool
DestinationPortMatch bool
DidMatch bool
IgnoreDestinationIPCIDRMatch bool
}
func ContextFrom ¶
func ContextFrom(ctx context.Context) *InboundContext
func ExtendContext ¶
func ExtendContext(ctx context.Context) (context.Context, *InboundContext)
func (*InboundContext) ResetRuleCache ¶
func (c *InboundContext) ResetRuleCache()
type InboundManager ¶ added in v1.12.4
type InboundRegistry ¶ added in v1.12.4
type InterfaceUpdateListener ¶
type InterfaceUpdateListener interface {
InterfaceUpdated()
}
type LegacyDNSTransport ¶ added in v1.12.4
type LegacyDNSTransport interface {
LegacyStrategy() C.DomainStrategy
LegacyClientSubnet() netip.Prefix
}
type Lifecycle ¶ added in v1.12.4
type Lifecycle interface {
Start(stage StartStage) error
Close() error
}
type LifecycleService ¶ added in v1.12.4
func NewLifecycleService ¶ added in v1.12.4
func NewLifecycleService(service SimpleLifecycle, name string) LifecycleService
type ManagedSSMServer ¶ added in v1.12.4
type ManagedSSMServer interface {
Inbound
SetTracker(tracker SSMTracker)
UpdateUsers(users []string, uPSKs []string) error
}
type NetworkInterface ¶ added in v1.12.4
type NetworkManager ¶ added in v1.12.4
type NetworkManager interface {
Lifecycle
InterfaceFinder() control.InterfaceFinder
UpdateInterfaces() error
DefaultNetworkInterface() *NetworkInterface
NetworkInterfaces() []NetworkInterface
AutoDetectInterface() bool
AutoDetectInterfaceFunc() control.Func
ProtectFunc() control.Func
DefaultOptions() NetworkOptions
RegisterAutoRedirectOutputMark(mark uint32) error
AutoRedirectOutputMark() uint32
AutoRedirectOutputMarkFunc() control.Func
NetworkMonitor() tun.NetworkUpdateMonitor
InterfaceMonitor() tun.DefaultInterfaceMonitor
PackageManager() tun.PackageManager
WIFIState() WIFIState
ResetNetwork()
UpdateWIFIState()
}
type NetworkOptions ¶ added in v1.12.4
type NetworkOptions struct {
BindInterface string
RoutingMark uint32
DomainResolver string
DomainResolveOptions DNSQueryOptions
NetworkStrategy *C.NetworkStrategy
NetworkType []C.InterfaceType
FallbackNetworkType []C.InterfaceType
FallbackDelay time.Duration
}
type OOBPacketHandler
deprecated
type OOBPacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error
}
Deprecated: use OOBPacketHandlerEx instead
type OOBPacketHandlerEx ¶ added in v1.12.4
type OutboundGroup ¶
type OutboundManager ¶ added in v1.12.4
type OutboundRegistry ¶ added in v1.12.4
type PacketConnectionHandler ¶
type PacketConnectionHandler interface {
NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}
Deprecated
type PacketConnectionHandlerEx ¶ added in v1.12.4
type PacketConnectionHandlerEx interface {
NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
}
type PacketConnectionHandlerFunc ¶
type PacketConnectionHandlerFunc = func(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
Deprecated
type PacketConnectionHandlerFuncEx ¶ added in v1.12.4
type PacketConnectionHandlerFuncEx = func(ctx context.Context, conn N.PacketConn, metadata InboundContext, onClose N.CloseHandlerFunc)
type PacketHandler
deprecated
type PacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error
}
Deprecated: use PacketHandlerEx instead
type PacketHandlerEx ¶ added in v1.12.4
type Router ¶
type Router interface {
Lifecycle
ConnectionRouter
PreMatch(metadata InboundContext) error
ConnectionRouterEx
RuleSet(tag string) (RuleSet, bool)
NeedWIFIState() bool
Rules() []Rule
AppendTracker(tracker ConnectionTracker)
ResetNetwork()
}
type Rule ¶
type Rule interface {
HeadlessRule
SimpleLifecycle
Type() string
Action() RuleAction
}
type RuleAction ¶ added in v1.12.4
type RuleSet ¶
type RuleSet interface {
Name() string
StartContext(ctx context.Context, startContext *HTTPStartContext) error
PostStart() error
Metadata() RuleSetMetadata
ExtractIPSet() []*netipx.IPSet
IncRef()
DecRef()
Cleanup()
RegisterCallback(callback RuleSetUpdateCallback) *list.Element[RuleSetUpdateCallback]
UnregisterCallback(element *list.Element[RuleSetUpdateCallback])
Close() error
HeadlessRule
}
type RuleSetMetadata ¶
type RuleSetUpdateCallback ¶
type RuleSetUpdateCallback func(it RuleSet)
type SSMTracker ¶ added in v1.12.4
type SSMTracker interface {
TrackConnection(conn net.Conn, metadata InboundContext) net.Conn
TrackPacketConnection(conn N.PacketConn, metadata InboundContext) N.PacketConn
}
type SavedBinary ¶ added in v1.12.4
func (*SavedBinary) MarshalBinary ¶ added in v1.12.4
func (s *SavedBinary) MarshalBinary() ([]byte, error)
func (*SavedBinary) UnmarshalBinary ¶ added in v1.12.4
func (s *SavedBinary) UnmarshalBinary(data []byte) error
type ServiceManager ¶ added in v1.12.4
type ServiceRegistry ¶ added in v1.12.4
type SimpleLifecycle ¶ added in v1.12.4
type StartStage ¶ added in v1.12.4
type StartStage uint8
const ( StartStateInitialize StartStage = iota StartStateStart StartStatePostStart StartStateStarted )
func (StartStage) String ¶ added in v1.12.4
func (s StartStage) String() string
type TCPInjectableInbound ¶ added in v1.12.4
type TCPInjectableInbound interface {
Inbound
ConnectionHandlerEx
}
type TimeService ¶
type TimeService interface {
SimpleLifecycle
TimeFunc() func() time.Time
}
type UDPInjectableInbound ¶ added in v1.12.4
type UDPInjectableInbound interface {
Inbound
PacketConnectionHandlerEx
}
type URLTestGroup ¶
type URLTestHistory ¶ added in v1.12.4
type URLTestHistoryStorage ¶ added in v1.12.4
type URLTestHistoryStorage interface {
SetHook(hook chan<- struct{})
LoadURLTestHistory(tag string) *URLTestHistory
DeleteURLTestHistory(tag string)
StoreURLTestHistory(tag string, history *URLTestHistory)
Close() error
}
type UpstreamHandlerAdapter
deprecated
type UpstreamHandlerAdapter interface {
N.TCPConnectionHandler
N.UDPConnectionHandler
E.Handler
}
Deprecated: use TCPConnectionHandlerEx instead
func NewRouteContextHandler
deprecated
func NewRouteContextHandler( router ConnectionRouter, logger logger.ContextLogger, ) UpstreamHandlerAdapter
Deprecated: Use ConnectionRouterEx instead.
func NewRouteHandler
deprecated
func NewRouteHandler( metadata InboundContext, router ConnectionRouter, logger logger.ContextLogger, ) UpstreamHandlerAdapter
Deprecated: Use ConnectionRouterEx instead.
func NewUpstreamContextHandler
deprecated
func NewUpstreamContextHandler( connectionHandler ConnectionHandlerFunc, packetHandler PacketConnectionHandlerFunc, errorHandler E.Handler, ) UpstreamHandlerAdapter
Deprecated: Use NewUpstreamContextHandlerEx instead.
func NewUpstreamHandler ¶
func NewUpstreamHandler( metadata InboundContext, connectionHandler ConnectionHandlerFunc, packetHandler PacketConnectionHandlerFunc, errorHandler E.Handler, ) UpstreamHandlerAdapter
Deprecated
type UpstreamHandlerAdapterEx ¶ added in v1.12.4
type UpstreamHandlerAdapterEx interface {
N.TCPConnectionHandlerEx
N.UDPConnectionHandlerEx
}
func NewRouteContextHandlerEx ¶ added in v1.12.4
func NewRouteContextHandlerEx( router ConnectionRouterEx, ) UpstreamHandlerAdapterEx
func NewRouteHandlerEx ¶ added in v1.12.4
func NewRouteHandlerEx( metadata InboundContext, router ConnectionRouterEx, ) UpstreamHandlerAdapterEx
func NewUpstreamContextHandlerEx ¶ added in v1.12.4
func NewUpstreamContextHandlerEx( connectionHandler ConnectionHandlerFuncEx, packetHandler PacketConnectionHandlerFuncEx, ) UpstreamHandlerAdapterEx
func NewUpstreamHandlerEx ¶ added in v1.12.4
func NewUpstreamHandlerEx( metadata InboundContext, connectionHandler ConnectionHandlerFuncEx, packetHandler PacketConnectionHandlerFuncEx, ) UpstreamHandlerAdapterEx
type V2RayClientTransport ¶
type V2RayServer ¶
type V2RayServer interface {
LifecycleService
StatsService() ConnectionTracker
}
type V2RayServerTransport ¶
type V2RayServerTransportHandler ¶
type V2RayServerTransportHandler interface {
N.TCPConnectionHandlerEx
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.