route

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2024 License: GPL-2.0 Imports: 59 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadPortRange = E.New("bad port range")

Functions

func NewDNSRule

func NewDNSRule(router adapter.Router, logger log.ContextLogger, options option.DNSRule, checkServer bool) (adapter.DNSRule, error)

func NewHeadlessRule

func NewHeadlessRule(router adapter.Router, options option.HeadlessRule) (adapter.HeadlessRule, error)

func NewRule

func NewRule(router adapter.Router, logger log.ContextLogger, options option.Rule, checkOutbound bool) (adapter.Rule, error)

func NewRuleSet

func NewRuleSet(ctx context.Context, router adapter.Router, logger logger.ContextLogger, options option.RuleSet) (adapter.RuleSet, error)

Types

type AuthUserItem

type AuthUserItem struct {
	// contains filtered or unexported fields
}

func NewAuthUserItem

func NewAuthUserItem(users []string) *AuthUserItem

func (*AuthUserItem) Match

func (r *AuthUserItem) Match(metadata *adapter.InboundContext) bool

func (*AuthUserItem) String

func (r *AuthUserItem) String() string

type ClashModeItem

type ClashModeItem struct {
	// contains filtered or unexported fields
}

func NewClashModeItem

func NewClashModeItem(router adapter.Router, mode string) *ClashModeItem

func (*ClashModeItem) Match

func (r *ClashModeItem) Match(metadata *adapter.InboundContext) bool

func (*ClashModeItem) String

func (r *ClashModeItem) String() string

type DNSReverseMapping

type DNSReverseMapping struct {
	// contains filtered or unexported fields
}

func NewDNSReverseMapping

func NewDNSReverseMapping() *DNSReverseMapping

func (*DNSReverseMapping) Query

func (m *DNSReverseMapping) Query(address netip.Addr) (string, bool)

func (*DNSReverseMapping) Save

func (m *DNSReverseMapping) Save(address netip.Addr, domain string, ttl int)

type DefaultDNSRule

type DefaultDNSRule struct {
	// contains filtered or unexported fields
}

func NewDefaultDNSRule

func NewDefaultDNSRule(router adapter.Router, logger log.ContextLogger, options option.DefaultDNSRule) (*DefaultDNSRule, error)

func (*DefaultDNSRule) ClientSubnet

func (r *DefaultDNSRule) ClientSubnet() *netip.Addr

func (*DefaultDNSRule) Close

func (r *DefaultDNSRule) Close() error

func (*DefaultDNSRule) DisableCache

func (r *DefaultDNSRule) DisableCache() bool

func (*DefaultDNSRule) Match

func (r *DefaultDNSRule) Match(metadata *adapter.InboundContext) bool

func (*DefaultDNSRule) MatchAddressLimit

func (r *DefaultDNSRule) MatchAddressLimit(metadata *adapter.InboundContext) bool

func (*DefaultDNSRule) Outbound

func (r *DefaultDNSRule) Outbound() string

func (*DefaultDNSRule) RewriteTTL

func (r *DefaultDNSRule) RewriteTTL() *uint32

func (*DefaultDNSRule) Start

func (r *DefaultDNSRule) Start() error

func (*DefaultDNSRule) String

func (r *DefaultDNSRule) String() string

func (*DefaultDNSRule) Type

func (r *DefaultDNSRule) Type() string

func (*DefaultDNSRule) UpdateGeosite

func (r *DefaultDNSRule) UpdateGeosite() error

func (*DefaultDNSRule) WithAddressLimit

func (r *DefaultDNSRule) WithAddressLimit() bool

type DefaultHeadlessRule

type DefaultHeadlessRule struct {
	// contains filtered or unexported fields
}

func NewDefaultHeadlessRule

func NewDefaultHeadlessRule(router adapter.Router, options option.DefaultHeadlessRule) (*DefaultHeadlessRule, error)

func (*DefaultHeadlessRule) Close

func (r *DefaultHeadlessRule) Close() error

func (*DefaultHeadlessRule) Match

func (r *DefaultHeadlessRule) Match(metadata *adapter.InboundContext) bool

func (*DefaultHeadlessRule) Outbound

func (r *DefaultHeadlessRule) Outbound() string

func (*DefaultHeadlessRule) Start

func (r *DefaultHeadlessRule) Start() error

func (*DefaultHeadlessRule) String

func (r *DefaultHeadlessRule) String() string

func (*DefaultHeadlessRule) Type

func (r *DefaultHeadlessRule) Type() string

func (*DefaultHeadlessRule) UpdateGeosite

func (r *DefaultHeadlessRule) UpdateGeosite() error

type DefaultRule

type DefaultRule struct {
	// contains filtered or unexported fields
}

func NewDefaultRule

func NewDefaultRule(router adapter.Router, logger log.ContextLogger, options option.DefaultRule) (*DefaultRule, error)

func (*DefaultRule) Close

func (r *DefaultRule) Close() error

func (*DefaultRule) Match

func (r *DefaultRule) Match(metadata *adapter.InboundContext) bool

func (*DefaultRule) Outbound

func (r *DefaultRule) Outbound() string

func (*DefaultRule) Start

func (r *DefaultRule) Start() error

func (*DefaultRule) String

func (r *DefaultRule) String() string

func (*DefaultRule) Type

func (r *DefaultRule) Type() string

func (*DefaultRule) UpdateGeosite

func (r *DefaultRule) UpdateGeosite() error

type DomainItem

type DomainItem struct {
	// contains filtered or unexported fields
}

func NewDomainItem

func NewDomainItem(domains []string, domainSuffixes []string) *DomainItem

func NewRawDomainItem

func NewRawDomainItem(matcher *domain.Matcher) *DomainItem

func (*DomainItem) Match

func (r *DomainItem) Match(metadata *adapter.InboundContext) bool

func (*DomainItem) String

func (r *DomainItem) String() string

type DomainKeywordItem

type DomainKeywordItem struct {
	// contains filtered or unexported fields
}

func NewDomainKeywordItem

func NewDomainKeywordItem(keywords []string) *DomainKeywordItem

func (*DomainKeywordItem) Match

func (r *DomainKeywordItem) Match(metadata *adapter.InboundContext) bool

func (*DomainKeywordItem) String

func (r *DomainKeywordItem) String() string

type DomainRegexItem

type DomainRegexItem struct {
	// contains filtered or unexported fields
}

func NewDomainRegexItem

func NewDomainRegexItem(expressions []string) (*DomainRegexItem, error)

func (*DomainRegexItem) Match

func (r *DomainRegexItem) Match(metadata *adapter.InboundContext) bool

func (*DomainRegexItem) String

func (r *DomainRegexItem) String() string

type GeoIPItem

type GeoIPItem struct {
	// contains filtered or unexported fields
}

func NewGeoIPItem

func NewGeoIPItem(router adapter.Router, logger log.ContextLogger, isSource bool, codes []string) *GeoIPItem

func (*GeoIPItem) Match

func (r *GeoIPItem) Match(metadata *adapter.InboundContext) bool

func (*GeoIPItem) String

func (r *GeoIPItem) String() string

type GeositeItem

type GeositeItem struct {
	// contains filtered or unexported fields
}

func NewGeositeItem

func NewGeositeItem(router adapter.Router, logger log.ContextLogger, codes []string) *GeositeItem

func (*GeositeItem) Match

func (r *GeositeItem) Match(metadata *adapter.InboundContext) bool

func (*GeositeItem) String

func (r *GeositeItem) String() string

func (*GeositeItem) Update

func (r *GeositeItem) Update() error

type IPCIDRItem

type IPCIDRItem struct {
	// contains filtered or unexported fields
}

func NewIPCIDRItem

func NewIPCIDRItem(isSource bool, prefixStrings []string) (*IPCIDRItem, error)

func NewRawIPCIDRItem

func NewRawIPCIDRItem(isSource bool, ipSet *netipx.IPSet) *IPCIDRItem

func (*IPCIDRItem) Match

func (r *IPCIDRItem) Match(metadata *adapter.InboundContext) bool

func (*IPCIDRItem) String

func (r *IPCIDRItem) String() string

type IPIsPrivateItem

type IPIsPrivateItem struct {
	// contains filtered or unexported fields
}

func NewIPIsPrivateItem

func NewIPIsPrivateItem(isSource bool) *IPIsPrivateItem

func (*IPIsPrivateItem) Match

func (r *IPIsPrivateItem) Match(metadata *adapter.InboundContext) bool

func (*IPIsPrivateItem) String

func (r *IPIsPrivateItem) String() string

type IPVersionItem

type IPVersionItem struct {
	// contains filtered or unexported fields
}

func NewIPVersionItem

func NewIPVersionItem(isIPv6 bool) *IPVersionItem

func (*IPVersionItem) Match

func (r *IPVersionItem) Match(metadata *adapter.InboundContext) bool

func (*IPVersionItem) String

func (r *IPVersionItem) String() string

type InboundItem

type InboundItem struct {
	// contains filtered or unexported fields
}

func NewInboundRule

func NewInboundRule(inbounds []string) *InboundItem

func (*InboundItem) Match

func (r *InboundItem) Match(metadata *adapter.InboundContext) bool

func (*InboundItem) String

func (r *InboundItem) String() string

type LocalRuleSet

type LocalRuleSet struct {
	// contains filtered or unexported fields
}

func NewLocalRuleSet

func NewLocalRuleSet(router adapter.Router, options option.RuleSet) (*LocalRuleSet, error)

func (*LocalRuleSet) Close

func (s *LocalRuleSet) Close() error

func (*LocalRuleSet) Match

func (s *LocalRuleSet) Match(metadata *adapter.InboundContext) bool

func (*LocalRuleSet) Metadata

func (s *LocalRuleSet) Metadata() adapter.RuleSetMetadata

func (*LocalRuleSet) PostStart

func (s *LocalRuleSet) PostStart() error

func (*LocalRuleSet) StartContext

func (s *LocalRuleSet) StartContext(ctx context.Context, startContext adapter.RuleSetStartContext) error

func (*LocalRuleSet) String

func (s *LocalRuleSet) String() string

type LogicalDNSRule

type LogicalDNSRule struct {
	// contains filtered or unexported fields
}

func NewLogicalDNSRule

func NewLogicalDNSRule(router adapter.Router, logger log.ContextLogger, options option.LogicalDNSRule) (*LogicalDNSRule, error)

func (*LogicalDNSRule) ClientSubnet

func (r *LogicalDNSRule) ClientSubnet() *netip.Addr

func (*LogicalDNSRule) Close

func (r *LogicalDNSRule) Close() error

func (*LogicalDNSRule) DisableCache

func (r *LogicalDNSRule) DisableCache() bool

func (*LogicalDNSRule) Match

func (r *LogicalDNSRule) Match(metadata *adapter.InboundContext) bool

func (*LogicalDNSRule) MatchAddressLimit

func (r *LogicalDNSRule) MatchAddressLimit(metadata *adapter.InboundContext) bool

func (*LogicalDNSRule) Outbound

func (r *LogicalDNSRule) Outbound() string

func (*LogicalDNSRule) RewriteTTL

func (r *LogicalDNSRule) RewriteTTL() *uint32

func (*LogicalDNSRule) Start

func (r *LogicalDNSRule) Start() error

func (*LogicalDNSRule) String

func (r *LogicalDNSRule) String() string

func (*LogicalDNSRule) Type

func (r *LogicalDNSRule) Type() string

func (*LogicalDNSRule) UpdateGeosite

func (r *LogicalDNSRule) UpdateGeosite() error

func (*LogicalDNSRule) WithAddressLimit

func (r *LogicalDNSRule) WithAddressLimit() bool

type LogicalHeadlessRule

type LogicalHeadlessRule struct {
	// contains filtered or unexported fields
}

func NewLogicalHeadlessRule

func NewLogicalHeadlessRule(router adapter.Router, options option.LogicalHeadlessRule) (*LogicalHeadlessRule, error)

func (*LogicalHeadlessRule) Close

func (r *LogicalHeadlessRule) Close() error

func (*LogicalHeadlessRule) Match

func (r *LogicalHeadlessRule) Match(metadata *adapter.InboundContext) bool

func (*LogicalHeadlessRule) Outbound

func (r *LogicalHeadlessRule) Outbound() string

func (*LogicalHeadlessRule) Start

func (r *LogicalHeadlessRule) Start() error

func (*LogicalHeadlessRule) String

func (r *LogicalHeadlessRule) String() string

func (*LogicalHeadlessRule) Type

func (r *LogicalHeadlessRule) Type() string

func (*LogicalHeadlessRule) UpdateGeosite

func (r *LogicalHeadlessRule) UpdateGeosite() error

type LogicalRule

type LogicalRule struct {
	// contains filtered or unexported fields
}

func NewLogicalRule

func NewLogicalRule(router adapter.Router, logger log.ContextLogger, options option.LogicalRule) (*LogicalRule, error)

func (*LogicalRule) Close

func (r *LogicalRule) Close() error

func (*LogicalRule) Match

func (r *LogicalRule) Match(metadata *adapter.InboundContext) bool

func (*LogicalRule) Outbound

func (r *LogicalRule) Outbound() string

func (*LogicalRule) Start

func (r *LogicalRule) Start() error

func (*LogicalRule) String

func (r *LogicalRule) String() string

func (*LogicalRule) Type

func (r *LogicalRule) Type() string

func (*LogicalRule) UpdateGeosite

func (r *LogicalRule) UpdateGeosite() error

type NetworkItem

type NetworkItem struct {
	// contains filtered or unexported fields
}

func NewNetworkItem

func NewNetworkItem(networks []string) *NetworkItem

func (*NetworkItem) Match

func (r *NetworkItem) Match(metadata *adapter.InboundContext) bool

func (*NetworkItem) String

func (r *NetworkItem) String() string

type OutboundItem

type OutboundItem struct {
	// contains filtered or unexported fields
}

func NewOutboundRule

func NewOutboundRule(outbounds []string) *OutboundItem

func (*OutboundItem) Match

func (r *OutboundItem) Match(metadata *adapter.InboundContext) bool

func (*OutboundItem) String

func (r *OutboundItem) String() string

type PackageNameItem

type PackageNameItem struct {
	// contains filtered or unexported fields
}

func NewPackageNameItem

func NewPackageNameItem(packageNameList []string) *PackageNameItem

func (*PackageNameItem) Match

func (r *PackageNameItem) Match(metadata *adapter.InboundContext) bool

func (*PackageNameItem) String

func (r *PackageNameItem) String() string

type PortItem

type PortItem struct {
	// contains filtered or unexported fields
}

func NewPortItem

func NewPortItem(isSource bool, ports []uint16) *PortItem

func (*PortItem) Match

func (r *PortItem) Match(metadata *adapter.InboundContext) bool

func (*PortItem) String

func (r *PortItem) String() string

type PortRangeItem

type PortRangeItem struct {
	// contains filtered or unexported fields
}

func NewPortRangeItem

func NewPortRangeItem(isSource bool, rangeList []string) (*PortRangeItem, error)

func (*PortRangeItem) Match

func (r *PortRangeItem) Match(metadata *adapter.InboundContext) bool

func (*PortRangeItem) String

func (r *PortRangeItem) String() string

type ProcessItem

type ProcessItem struct {
	// contains filtered or unexported fields
}

func NewProcessItem

func NewProcessItem(processNameList []string) *ProcessItem

func (*ProcessItem) Match

func (r *ProcessItem) Match(metadata *adapter.InboundContext) bool

func (*ProcessItem) String

func (r *ProcessItem) String() string

type ProcessPathItem

type ProcessPathItem struct {
	// contains filtered or unexported fields
}

func NewProcessPathItem

func NewProcessPathItem(processNameList []string) *ProcessPathItem

func (*ProcessPathItem) Match

func (r *ProcessPathItem) Match(metadata *adapter.InboundContext) bool

func (*ProcessPathItem) String

func (r *ProcessPathItem) String() string

type ProtocolItem

type ProtocolItem struct {
	// contains filtered or unexported fields
}

func NewProtocolItem

func NewProtocolItem(protocols []string) *ProtocolItem

func (*ProtocolItem) Match

func (r *ProtocolItem) Match(metadata *adapter.InboundContext) bool

func (*ProtocolItem) String

func (r *ProtocolItem) String() string

type QueryTypeItem

type QueryTypeItem struct {
	// contains filtered or unexported fields
}

func NewQueryTypeItem

func NewQueryTypeItem(typeList []option.DNSQueryType) *QueryTypeItem

func (*QueryTypeItem) Match

func (r *QueryTypeItem) Match(metadata *adapter.InboundContext) bool

func (*QueryTypeItem) String

func (r *QueryTypeItem) String() string

type RemoteRuleSet

type RemoteRuleSet struct {
	// contains filtered or unexported fields
}

func NewRemoteRuleSet

func NewRemoteRuleSet(ctx context.Context, router adapter.Router, logger logger.ContextLogger, options option.RuleSet) *RemoteRuleSet

func (*RemoteRuleSet) Close

func (s *RemoteRuleSet) Close() error

func (*RemoteRuleSet) Match

func (s *RemoteRuleSet) Match(metadata *adapter.InboundContext) bool

func (*RemoteRuleSet) Metadata

func (s *RemoteRuleSet) Metadata() adapter.RuleSetMetadata

func (*RemoteRuleSet) PostStart

func (s *RemoteRuleSet) PostStart() error

func (*RemoteRuleSet) StartContext

func (s *RemoteRuleSet) StartContext(ctx context.Context, startContext adapter.RuleSetStartContext) error

func (*RemoteRuleSet) String

func (s *RemoteRuleSet) String() string

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(
	ctx context.Context,
	logFactory log.Factory,
	options option.RouteOptions,
	dnsOptions option.DNSOptions,
	ntpOptions option.NTPOptions,
	inbounds []option.Inbound,
	platformInterface platform.Interface,
) (*Router, error)

func (*Router) AutoDetectInterface

func (r *Router) AutoDetectInterface() bool

func (*Router) AutoDetectInterfaceFunc

func (r *Router) AutoDetectInterfaceFunc() control.Func

func (*Router) ClashServer

func (r *Router) ClashServer() adapter.ClashServer

func (*Router) ClearDNSCache

func (r *Router) ClearDNSCache()

func (*Router) Close

func (r *Router) Close() error

func (*Router) DefaultInterface

func (r *Router) DefaultInterface() string

func (*Router) DefaultMark

func (r *Router) DefaultMark() int

func (*Router) DefaultOutbound

func (r *Router) DefaultOutbound(network string) (adapter.Outbound, error)

func (*Router) Exchange

func (r *Router) Exchange(ctx context.Context, message *mDNS.Msg) (*mDNS.Msg, error)

func (*Router) FakeIPStore

func (r *Router) FakeIPStore() adapter.FakeIPStore

func (*Router) GeoIPReader

func (r *Router) GeoIPReader() *geoip.Reader

func (*Router) Initialize

func (r *Router) Initialize(inbounds []adapter.Inbound, outbounds []adapter.Outbound, defaultOutbound func() adapter.Outbound) error

func (*Router) InterfaceFinder

func (r *Router) InterfaceFinder() control.InterfaceFinder

func (*Router) InterfaceMonitor

func (r *Router) InterfaceMonitor() tun.DefaultInterfaceMonitor

func (*Router) LoadGeosite

func (r *Router) LoadGeosite(code string) (adapter.Rule, error)

func (*Router) Lookup

func (r *Router) Lookup(ctx context.Context, domain string, strategy dns.DomainStrategy) ([]netip.Addr, error)

func (*Router) LookupDefault

func (r *Router) LookupDefault(ctx context.Context, domain string) ([]netip.Addr, error)

func (*Router) NeedWIFIState

func (r *Router) NeedWIFIState() bool

func (*Router) NetworkMonitor

func (r *Router) NetworkMonitor() tun.NetworkUpdateMonitor

func (*Router) NewError

func (r *Router) NewError(ctx context.Context, err error)

func (*Router) OnPackagesUpdated

func (r *Router) OnPackagesUpdated(packages int, sharedUsers int)

func (*Router) Outbound

func (r *Router) Outbound(tag string) (adapter.Outbound, bool)

func (*Router) Outbounds

func (r *Router) Outbounds() []adapter.Outbound

func (*Router) PackageManager

func (r *Router) PackageManager() tun.PackageManager

func (*Router) PostStart

func (r *Router) PostStart() error

func (*Router) PreStart

func (r *Router) PreStart() error

func (*Router) ResetNetwork

func (r *Router) ResetNetwork() error

func (*Router) RouteConnection

func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error

func (*Router) RoutePacketConnection

func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata adapter.InboundContext) error

func (*Router) RuleSet

func (r *Router) RuleSet(tag string) (adapter.RuleSet, bool)

func (*Router) Rules

func (r *Router) Rules() []adapter.Rule

func (*Router) SetClashServer

func (r *Router) SetClashServer(server adapter.ClashServer)

func (*Router) SetV2RayServer

func (r *Router) SetV2RayServer(server adapter.V2RayServer)

func (*Router) Start

func (r *Router) Start() error

func (*Router) UpdateInterfaces

func (r *Router) UpdateInterfaces() error

func (*Router) V2RayServer

func (r *Router) V2RayServer() adapter.V2RayServer

func (*Router) WIFIState

func (r *Router) WIFIState() adapter.WIFIState

type RuleItem

type RuleItem interface {
	Match(metadata *adapter.InboundContext) bool
	String() string
}

type RuleSetItem

type RuleSetItem struct {
	// contains filtered or unexported fields
}

func NewRuleSetItem

func NewRuleSetItem(router adapter.Router, tagList []string, ipCIDRMatchSource bool) *RuleSetItem

func (*RuleSetItem) ContainsDestinationIPCIDRRule

func (r *RuleSetItem) ContainsDestinationIPCIDRRule() bool

func (*RuleSetItem) Match

func (r *RuleSetItem) Match(metadata *adapter.InboundContext) bool

func (*RuleSetItem) Start

func (r *RuleSetItem) Start() error

func (*RuleSetItem) String

func (r *RuleSetItem) String() string

type RuleSetStartContext

type RuleSetStartContext struct {
	// contains filtered or unexported fields
}

func NewRuleSetStartContext

func NewRuleSetStartContext() *RuleSetStartContext

func (*RuleSetStartContext) Close

func (c *RuleSetStartContext) Close()

func (*RuleSetStartContext) HTTPClient

func (c *RuleSetStartContext) HTTPClient(detour string, dialer N.Dialer) *http.Client

type UserIdItem

type UserIdItem struct {
	// contains filtered or unexported fields
}

func NewUserIDItem

func NewUserIDItem(userIdList []int32) *UserIdItem

func (*UserIdItem) Match

func (r *UserIdItem) Match(metadata *adapter.InboundContext) bool

func (*UserIdItem) String

func (r *UserIdItem) String() string

type UserItem

type UserItem struct {
	// contains filtered or unexported fields
}

func NewUserItem

func NewUserItem(users []string) *UserItem

func (*UserItem) Match

func (r *UserItem) Match(metadata *adapter.InboundContext) bool

func (*UserItem) String

func (r *UserItem) String() string

type WIFIBSSIDItem

type WIFIBSSIDItem struct {
	// contains filtered or unexported fields
}

func NewWIFIBSSIDItem

func NewWIFIBSSIDItem(router adapter.Router, bssidList []string) *WIFIBSSIDItem

func (*WIFIBSSIDItem) Match

func (r *WIFIBSSIDItem) Match(metadata *adapter.InboundContext) bool

func (*WIFIBSSIDItem) String

func (r *WIFIBSSIDItem) String() string

type WIFISSIDItem

type WIFISSIDItem struct {
	// contains filtered or unexported fields
}

func NewWIFISSIDItem

func NewWIFISSIDItem(router adapter.Router, ssidList []string) *WIFISSIDItem

func (*WIFISSIDItem) Match

func (r *WIFISSIDItem) Match(metadata *adapter.InboundContext) bool

func (*WIFISSIDItem) String

func (r *WIFISSIDItem) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL