Documentation ¶
Index ¶
- func ContextWithRouter(ctx context.Context, router Router) context.Context
- func OutboundTag(detour Outbound) string
- func UpstreamMetadata(metadata InboundContext) M.Metadata
- func WithContext(ctx context.Context, inboundContext *InboundContext) context.Context
- type CacheFile
- type ClashServer
- type ConnectionHandler
- type ConnectionHandlerFunc
- type ConnectionRouter
- type DNSRule
- type FakeIPMetadata
- type FakeIPStorage
- type FakeIPStore
- type FakeIPTransport
- type HeadlessRule
- type Inbound
- type InboundContext
- type InjectableInbound
- type InterfaceUpdateListener
- type OOBPacketHandler
- type Outbound
- type OutboundGroup
- type PacketConnectionHandler
- type PacketConnectionHandlerFunc
- type PacketHandler
- type PostStarter
- type PreStarter
- type Router
- type Rule
- type RuleSet
- type RuleSetMetadata
- type RuleSetStartContext
- type SavedRuleSet
- type Service
- type TimeService
- type Tracker
- type URLTestGroup
- type UpstreamHandlerAdapter
- func NewRouteContextHandler(router ConnectionRouter, logger logger.ContextLogger) UpstreamHandlerAdapter
- func NewRouteHandler(metadata InboundContext, router ConnectionRouter, logger logger.ContextLogger) UpstreamHandlerAdapter
- func NewUpstreamContextHandler(connectionHandler ConnectionHandlerFunc, ...) UpstreamHandlerAdapter
- func NewUpstreamHandler(metadata InboundContext, connectionHandler ConnectionHandlerFunc, ...) UpstreamHandlerAdapter
- type V2RayClientTransport
- type V2RayServer
- type V2RayServerTransport
- type V2RayServerTransportHandler
- type V2RayStatsService
- type WIFIState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithRouter ¶ added in v1.2.0
func OutboundTag ¶
func UpstreamMetadata ¶
func UpstreamMetadata(metadata InboundContext) M.Metadata
func WithContext ¶
func WithContext(ctx context.Context, inboundContext *InboundContext) context.Context
Types ¶
type CacheFile ¶ added in v1.8.0
type CacheFile interface { Service PreStarter StoreFakeIP() bool FakeIPStorage 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) *SavedRuleSet SaveRuleSet(tag string, set *SavedRuleSet) error }
type ClashServer ¶
type ClashServer interface { Service PreStarter Mode() string ModeList() []string HistoryStorage() *urltest.HistoryStorage RoutedConnection(ctx context.Context, conn net.Conn, metadata InboundContext, matchedRule Rule) (net.Conn, Tracker) RoutedPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext, matchedRule Rule) (N.PacketConn, Tracker) }
type ConnectionHandler ¶
type ConnectionHandlerFunc ¶
type ConnectionRouter ¶ added in v1.7.0
type ConnectionRouter interface { RouteConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error }
type FakeIPMetadata ¶ added in v1.3.0
type FakeIPMetadata struct { Inet4Range netip.Prefix Inet6Range netip.Prefix Inet4Current netip.Addr Inet6Current netip.Addr }
func (*FakeIPMetadata) MarshalBinary ¶ added in v1.3.0
func (m *FakeIPMetadata) MarshalBinary() (data []byte, err error)
func (*FakeIPMetadata) UnmarshalBinary ¶ added in v1.3.0
func (m *FakeIPMetadata) UnmarshalBinary(data []byte) error
type FakeIPStorage ¶ added in v1.3.0
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 ¶ added in v1.3.0
type FakeIPTransport ¶ added in v1.3.0
type FakeIPTransport interface {
dns.Transport
Store() FakeIPStore
}
type HeadlessRule ¶ added in v1.8.0
type HeadlessRule interface {
Match(metadata *InboundContext) bool
}
type InboundContext ¶
type InboundContext struct { Inbound string InboundType string IPVersion uint8 Network string Source M.Socksaddr Destination M.Socksaddr Domain string Protocol string User string Outbound string InboundDetour string LastInbound string OriginDestination M.Socksaddr InboundOptions option.InboundOptions DestinationAddresses []netip.Addr SourceGeoIPCode string GeoIPCode string ProcessInfo *process.Info QueryType uint16 FakeIP bool IPCIDRMatchSource bool SourceAddressMatch bool SourcePortMatch bool DestinationAddressMatch bool DestinationPortMatch bool }
func AppendContext ¶
func AppendContext(ctx context.Context) (context.Context, *InboundContext)
func ContextFrom ¶
func ContextFrom(ctx context.Context) *InboundContext
func ExtendContext ¶ added in v1.5.5
func ExtendContext(ctx context.Context) (context.Context, *InboundContext)
func (*InboundContext) ResetRuleCache ¶ added in v1.8.0
func (c *InboundContext) ResetRuleCache()
type InjectableInbound ¶ added in v1.0.1
type InjectableInbound interface { Inbound Network() []string NewConnection(ctx context.Context, conn net.Conn, metadata InboundContext) error NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error }
type InterfaceUpdateListener ¶ added in v1.1.0
type InterfaceUpdateListener interface {
InterfaceUpdated()
}
type OOBPacketHandler ¶
type OOBPacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, oob []byte, metadata InboundContext) error
}
type OutboundGroup ¶
type PacketConnectionHandler ¶
type PacketConnectionHandler interface {
NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
}
type PacketConnectionHandlerFunc ¶
type PacketConnectionHandlerFunc = func(ctx context.Context, conn N.PacketConn, metadata InboundContext) error
type PacketHandler ¶
type PacketHandler interface {
NewPacket(ctx context.Context, conn N.PacketConn, buffer *buf.Buffer, metadata InboundContext) error
}
type PostStarter ¶ added in v1.3.3
type PostStarter interface {
PostStart() error
}
type PreStarter ¶ added in v1.2.0
type PreStarter interface {
PreStart() error
}
type Router ¶
type Router interface { Service PreStarter PostStarter Outbounds() []Outbound Outbound(tag string) (Outbound, bool) DefaultOutbound(network string) (Outbound, error) FakeIPStore() FakeIPStore ConnectionRouter GeoIPReader() *geoip.Reader LoadGeosite(code string) (Rule, error) RuleSet(tag string) (RuleSet, bool) Exchange(ctx context.Context, message *mdns.Msg) (*mdns.Msg, error) Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error) LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error) ClearDNSCache() InterfaceFinder() control.InterfaceFinder UpdateInterfaces() error DefaultInterface() string AutoDetectInterface() bool AutoDetectInterfaceFunc() control.Func DefaultMark() int NetworkMonitor() tun.NetworkUpdateMonitor InterfaceMonitor() tun.DefaultInterfaceMonitor PackageManager() tun.PackageManager WIFIState() WIFIState Rules() []Rule ClashServer() ClashServer SetClashServer(server ClashServer) V2RayServer() V2RayServer SetV2RayServer(server V2RayServer) ResetNetwork() error }
func RouterFromContext ¶ added in v1.2.0
type RuleSet ¶ added in v1.8.0
type RuleSet interface { StartContext(ctx context.Context, startContext RuleSetStartContext) error PostStart() error Metadata() RuleSetMetadata Close() error HeadlessRule }
type RuleSetMetadata ¶ added in v1.8.0
type RuleSetStartContext ¶ added in v1.8.0
type SavedRuleSet ¶ added in v1.8.0
func (*SavedRuleSet) MarshalBinary ¶ added in v1.8.0
func (s *SavedRuleSet) MarshalBinary() ([]byte, error)
func (*SavedRuleSet) UnmarshalBinary ¶ added in v1.8.0
func (s *SavedRuleSet) UnmarshalBinary(data []byte) error
type TimeService ¶ added in v1.2.0
type URLTestGroup ¶ added in v1.3.0
type UpstreamHandlerAdapter ¶
type UpstreamHandlerAdapter interface { N.TCPConnectionHandler N.UDPConnectionHandler E.Handler }
func NewRouteContextHandler ¶ added in v1.7.0
func NewRouteContextHandler( router ConnectionRouter, logger logger.ContextLogger, ) UpstreamHandlerAdapter
func NewRouteHandler ¶ added in v1.7.0
func NewRouteHandler( metadata InboundContext, router ConnectionRouter, logger logger.ContextLogger, ) UpstreamHandlerAdapter
func NewUpstreamContextHandler ¶
func NewUpstreamContextHandler( connectionHandler ConnectionHandlerFunc, packetHandler PacketConnectionHandlerFunc, errorHandler E.Handler, ) UpstreamHandlerAdapter
func NewUpstreamHandler ¶
func NewUpstreamHandler( metadata InboundContext, connectionHandler ConnectionHandlerFunc, packetHandler PacketConnectionHandlerFunc, errorHandler E.Handler, ) UpstreamHandlerAdapter
type V2RayClientTransport ¶ added in v1.0.1
type V2RayServer ¶ added in v1.1.0
type V2RayServer interface { Service StatsService() V2RayStatsService }
type V2RayServerTransport ¶ added in v1.0.1
type V2RayServerTransportHandler ¶ added in v1.2.0
type V2RayServerTransportHandler interface { N.TCPConnectionHandler E.Handler }
type V2RayStatsService ¶ added in v1.1.0
Click to show internal directories.
Click to hide internal directories.