common

package
v1.19.32-clash.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: GPL-3.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoResolve = "no-resolve"
	Src       = "src"
)

params

Functions

func ParseParams

func ParseParams(params []string) (isSrc bool, noResolve bool)

func ParseRulePayload

func ParseRulePayload(ruleRaw string, needTarget bool) (tp, payload, target string, params []string)

ParseRulePayload parse rule format like: `tp,payload,target(,params...)` or `tp,payload(,params...)` needTarget control the format contains `target` in string

Types

type ASN

type ASN struct {
	Base
	// contains filtered or unexported fields
}

func NewIPASN

func NewIPASN(asn string, adapter string, isSrc, noResolveIP bool) (*ASN, error)

func (*ASN) Adapter

func (a *ASN) Adapter() string

func (*ASN) GetASN

func (a *ASN) GetASN() string

func (*ASN) Match

func (a *ASN) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*ASN) Payload

func (a *ASN) Payload() string

func (*ASN) RuleType

func (a *ASN) RuleType() C.RuleType

type Base

type Base struct {
}

func (*Base) ProviderNames

func (b *Base) ProviderNames() []string

type DSCP

type DSCP struct {
	Base
	// contains filtered or unexported fields
}

func NewDSCP

func NewDSCP(dscp string, adapter string) (*DSCP, error)

func (*DSCP) Adapter

func (d *DSCP) Adapter() string

func (*DSCP) Match

func (d *DSCP) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*DSCP) Payload

func (d *DSCP) Payload() string

func (*DSCP) RuleType

func (d *DSCP) RuleType() C.RuleType

type Domain

type Domain struct {
	Base
	// contains filtered or unexported fields
}

func NewDomain

func NewDomain(domain string, adapter string) *Domain

func (*Domain) Adapter

func (d *Domain) Adapter() string

func (*Domain) Match

func (d *Domain) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*Domain) Payload

func (d *Domain) Payload() string

func (*Domain) RuleType

func (d *Domain) RuleType() C.RuleType

type DomainKeyword

type DomainKeyword struct {
	Base
	// contains filtered or unexported fields
}

func NewDomainKeyword

func NewDomainKeyword(keyword string, adapter string) *DomainKeyword

func (*DomainKeyword) Adapter

func (dk *DomainKeyword) Adapter() string

func (*DomainKeyword) Match

func (dk *DomainKeyword) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*DomainKeyword) Payload

func (dk *DomainKeyword) Payload() string

func (*DomainKeyword) RuleType

func (dk *DomainKeyword) RuleType() C.RuleType

type DomainRegex

type DomainRegex struct {
	Base
	// contains filtered or unexported fields
}

func NewDomainRegex

func NewDomainRegex(regex string, adapter string) (*DomainRegex, error)

func (*DomainRegex) Adapter

func (dr *DomainRegex) Adapter() string

func (*DomainRegex) Match

func (dr *DomainRegex) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*DomainRegex) Payload

func (dr *DomainRegex) Payload() string

func (*DomainRegex) RuleType

func (dr *DomainRegex) RuleType() C.RuleType

type DomainSuffix

type DomainSuffix struct {
	Base
	// contains filtered or unexported fields
}

func NewDomainSuffix

func NewDomainSuffix(suffix string, adapter string) *DomainSuffix

func (*DomainSuffix) Adapter

func (ds *DomainSuffix) Adapter() string

func (*DomainSuffix) Match

func (ds *DomainSuffix) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*DomainSuffix) Payload

func (ds *DomainSuffix) Payload() string

func (*DomainSuffix) RuleType

func (ds *DomainSuffix) RuleType() C.RuleType

type DomainWildcard

type DomainWildcard struct {
	Base
	// contains filtered or unexported fields
}

func NewDomainWildcard

func NewDomainWildcard(pattern string, adapter string) (*DomainWildcard, error)

func (*DomainWildcard) Adapter

func (dw *DomainWildcard) Adapter() string

func (*DomainWildcard) Match

func (dw *DomainWildcard) Match(metadata *C.Metadata, _ C.RuleMatchHelper) (bool, string)

func (*DomainWildcard) Payload

func (dw *DomainWildcard) Payload() string

func (*DomainWildcard) RuleType

func (dw *DomainWildcard) RuleType() C.RuleType

type GEOIP

type GEOIP struct {
	Base
	// contains filtered or unexported fields
}

func NewGEOIP

func NewGEOIP(country string, adapter string, isSrc, noResolveIP bool) (*GEOIP, error)

func (*GEOIP) Adapter

func (g *GEOIP) Adapter() string

func (*GEOIP) DnsFallbackFilter

func (g *GEOIP) DnsFallbackFilter() C.IpMatcher

func (*GEOIP) GetCountry

func (g *GEOIP) GetCountry() string

func (*GEOIP) GetIPMatcher

func (g *GEOIP) GetIPMatcher() (router.IPMatcher, error)

func (*GEOIP) GetRecodeSize

func (g *GEOIP) GetRecodeSize() int

func (*GEOIP) Match

func (g *GEOIP) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*GEOIP) MatchIp

func (g *GEOIP) MatchIp(ip netip.Addr) bool

MatchIp implements C.IpMatcher

func (*GEOIP) Payload

func (g *GEOIP) Payload() string

func (*GEOIP) RuleType

func (g *GEOIP) RuleType() C.RuleType

type GEOSITE

type GEOSITE struct {
	Base
	// contains filtered or unexported fields
}

func NewGEOSITE

func NewGEOSITE(country string, adapter string) (*GEOSITE, error)

func (*GEOSITE) Adapter

func (gs *GEOSITE) Adapter() string

func (*GEOSITE) GetDomainMatcher

func (gs *GEOSITE) GetDomainMatcher() (router.DomainMatcher, error)

func (*GEOSITE) GetRecodeSize

func (gs *GEOSITE) GetRecodeSize() int

func (*GEOSITE) Match

func (gs *GEOSITE) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*GEOSITE) MatchDomain

func (gs *GEOSITE) MatchDomain(domain string) bool

MatchDomain implements C.DomainMatcher

func (*GEOSITE) Payload

func (gs *GEOSITE) Payload() string

func (*GEOSITE) RuleType

func (gs *GEOSITE) RuleType() C.RuleType

type IPCIDR

type IPCIDR struct {
	Base
	// contains filtered or unexported fields
}

func NewIPCIDR

func NewIPCIDR(s string, adapter string, opts ...IPCIDROption) (*IPCIDR, error)

func (*IPCIDR) Adapter

func (i *IPCIDR) Adapter() string

func (*IPCIDR) ClashIsSourceIP

func (i *IPCIDR) ClashIsSourceIP() bool

func (*IPCIDR) ClashResolvesIP

func (i *IPCIDR) ClashResolvesIP() bool

func (*IPCIDR) Match

func (i *IPCIDR) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*IPCIDR) Payload

func (i *IPCIDR) Payload() string

func (*IPCIDR) RuleType

func (i *IPCIDR) RuleType() C.RuleType

type IPCIDROption

type IPCIDROption func(*IPCIDR)

func WithIPCIDRNoResolve

func WithIPCIDRNoResolve(noResolve bool) IPCIDROption

func WithIPCIDRSourceIP

func WithIPCIDRSourceIP(b bool) IPCIDROption

type IPSuffix

type IPSuffix struct {
	Base
	// contains filtered or unexported fields
}

func NewIPSuffix

func NewIPSuffix(payload, adapter string, isSrc, noResolveIP bool) (*IPSuffix, error)

func (*IPSuffix) Adapter

func (is *IPSuffix) Adapter() string

func (*IPSuffix) Match

func (is *IPSuffix) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*IPSuffix) Payload

func (is *IPSuffix) Payload() string

func (*IPSuffix) RuleType

func (is *IPSuffix) RuleType() C.RuleType

type InName

type InName struct {
	Base
	// contains filtered or unexported fields
}

func NewInName

func NewInName(iNames, adapter string) (*InName, error)

func (*InName) Adapter

func (u *InName) Adapter() string

func (*InName) Match

func (u *InName) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*InName) Payload

func (u *InName) Payload() string

func (*InName) RuleType

func (u *InName) RuleType() C.RuleType

type InType

type InType struct {
	Base
	// contains filtered or unexported fields
}

func NewInType

func NewInType(iTypes, adapter string) (*InType, error)

func (*InType) Adapter

func (u *InType) Adapter() string

func (*InType) Match

func (u *InType) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*InType) Payload

func (u *InType) Payload() string

func (*InType) RuleType

func (u *InType) RuleType() C.RuleType

type InUser

type InUser struct {
	Base
	// contains filtered or unexported fields
}

func NewInUser

func NewInUser(iUsers, adapter string) (*InUser, error)

func (*InUser) Adapter

func (u *InUser) Adapter() string

func (*InUser) Match

func (u *InUser) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*InUser) Payload

func (u *InUser) Payload() string

func (*InUser) RuleType

func (u *InUser) RuleType() C.RuleType

type Match

type Match struct {
	Base
	// contains filtered or unexported fields
}

func NewMatch

func NewMatch(adapter string) *Match

func (*Match) Adapter

func (f *Match) Adapter() string

func (*Match) Match

func (f *Match) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*Match) Payload

func (f *Match) Payload() string

func (*Match) RuleType

func (f *Match) RuleType() C.RuleType

type NetworkType

type NetworkType struct {
	Base
	// contains filtered or unexported fields
}

func NewNetworkType

func NewNetworkType(network, adapter string) (*NetworkType, error)

func (*NetworkType) Adapter

func (n *NetworkType) Adapter() string

func (*NetworkType) Match

func (n *NetworkType) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*NetworkType) Payload

func (n *NetworkType) Payload() string

func (*NetworkType) RuleType

func (n *NetworkType) RuleType() C.RuleType

type ParseRuleFunc

type ParseRuleFunc func(tp, payload, target string, params []string, subRules map[string][]C.Rule) (C.Rule, error)

type Port

type Port struct {
	Base
	// contains filtered or unexported fields
}

func NewPort

func NewPort(port string, adapter string, ruleType C.RuleType) (*Port, error)

func (*Port) Adapter

func (p *Port) Adapter() string

func (*Port) Match

func (p *Port) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*Port) Payload

func (p *Port) Payload() string

func (*Port) RuleType

func (p *Port) RuleType() C.RuleType

type Process

type Process struct {
	Base
	// contains filtered or unexported fields
}

func NewProcess

func NewProcess(pattern string, adapter string, ruleType C.RuleType) (*Process, error)

func (*Process) Adapter

func (ps *Process) Adapter() string

func (*Process) Match

func (ps *Process) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*Process) Payload

func (ps *Process) Payload() string

func (*Process) RuleType

func (ps *Process) RuleType() C.RuleType

type RematchName

type RematchName struct {
	Base
	// contains filtered or unexported fields
}

func NewRematchName

func NewRematchName(iNames, adapter string) (*RematchName, error)

func (*RematchName) Adapter

func (u *RematchName) Adapter() string

func (*RematchName) Match

func (u *RematchName) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*RematchName) Payload

func (u *RematchName) Payload() string

func (*RematchName) RuleType

func (u *RematchName) RuleType() C.RuleType

type SourceAppIdentity

type SourceAppIdentity struct {
	Base
	// contains filtered or unexported fields
}

func NewSourceAppIdentity

func NewSourceAppIdentity(
	pattern string,
	adapter string,
	ruleType C.RuleType,
) (*SourceAppIdentity, error)

func (*SourceAppIdentity) Adapter

func (rule *SourceAppIdentity) Adapter() string

func (*SourceAppIdentity) Match

func (rule *SourceAppIdentity) Match(
	metadata *C.Metadata,
	helper C.RuleMatchHelper,
) (bool, string)

func (*SourceAppIdentity) Payload

func (rule *SourceAppIdentity) Payload() string

func (*SourceAppIdentity) RuleType

func (rule *SourceAppIdentity) RuleType() C.RuleType

type Uid

type Uid struct {
	Base
	// contains filtered or unexported fields
}

func NewUid

func NewUid(oUid, adapter string) (*Uid, error)

func (*Uid) Adapter

func (u *Uid) Adapter() string

func (*Uid) Match

func (u *Uid) Match(metadata *C.Metadata, helper C.RuleMatchHelper) (bool, string)

func (*Uid) Payload

func (u *Uid) Payload() string

func (*Uid) RuleType

func (u *Uid) RuleType() C.RuleType

Jump to

Keyboard shortcuts

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