provider

package
v1.19.34-clash.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: GPL-3.0 Imports: 43 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

View Source
const (
	ClashClassicalIndexStubType   = "CLASH-CLASSICAL-INDEX"
	ClashClassicalIndexStubSuffix = ".stub"
)
View Source
const (
	ClashDomainSetStubType = "CLASH-DOMAIN-SET"
	ClashIPCidrSetStubType = "CLASH-IPCIDR-SET"
)
View Source
const (
	ClashClassicalKeywordLimit = 20000
	ClashClassicalRegexLimit   = 1000
)
View Source
const (
	ClashClassicalOthersLimit = 20000
	ClashClassicalIPRunLimit  = 20000
)
View Source
const ClashMrsMappedCacheKeep = 3 * 24 * time.Hour
View Source
const ClashMrsMappedFormat = "CDS1+CIP1/1"

Variables

View Source
var (
	ErrNoPayload     = errors.New("file must have a `payload` field")
	ErrInvalidFormat = errors.New("invalid format")
)
View Source
var ClashClassicalSourceFallbackLimit int64 = 1 << 20
View Source
var ErrClassicalTooHeavy = errors.New("rule set too heavy for iOS")
View Source
var MrsMagicBytes = [4]byte{'M', 'R', 'S', 1} // MRSv1

Functions

func ClashCheckClassicalIndexFile

func ClashCheckClassicalIndexFile(path string) (uint32, error)

func ClashCheckMappedSet

func ClashCheckMappedSet(path string, behavior P.RuleBehavior) ([sha256.Size]byte, error)

func ClashClassicalIndexChecksumOf

func ClashClassicalIndexChecksumOf(path string, whole bool) (uint32, bool)

func ClashClassicalIndexStub

func ClashClassicalIndexStub(indexName string, checksum uint32, sourceName string, format P.RuleFormat) string

func ClashClassicalLines

func ClashClassicalLines(buf []byte, format P.RuleFormat) ([]string, error)

func ClashMappedSetChecksumOf

func ClashMappedSetChecksumOf(path string) ([sha256.Size]byte, bool)

func ClashMappedSetStub

func ClashMappedSetStub(stubType, name string, sum [sha256.Size]byte, count int) string

func ClashMrsMappedCacheDirectory

func ClashMrsMappedCacheDirectory() string

func ClashRuleProviderSchemaType

func ClashRuleProviderSchemaType() reflect.Type

func ClashSetMrsMappedCacheDirectory

func ClashSetMrsMappedCacheDirectory(directory, identity string)

func ClashStubbedPayload

func ClashStubbedPayload(payload []byte) bool

func ClashSweepMrsMappedCache

func ClashSweepMrsMappedCache(age time.Duration)

func ConvertMain

func ConvertMain(args []string)

func ConvertToMrs

func ConvertToMrs(buf []byte, behavior P.RuleBehavior, format P.RuleFormat, w io.Writer) (err error)

func NewClassicalStrategy

func NewClassicalStrategy(parse common.ParseRuleFunc) *classicalStrategy

func NewDomainStrategy

func NewDomainStrategy() *domainStrategy

func NewIPCidrStrategy

func NewIPCidrStrategy() *ipcidrStrategy

func NewInlineProvider

func NewInlineProvider(name string, behavior P.RuleBehavior, payload []string, parse common.ParseRuleFunc) P.RuleProvider

func NewRuleSetProvider

func NewRuleSetProvider(name string, behavior P.RuleBehavior, format P.RuleFormat, interval time.Duration, vehicle P.Vehicle, payload []string, bundleFile resource.BundleFile, parse common.ParseRuleFunc) P.RuleProvider

func ParseRuleProvider

func ParseRuleProvider(name string, mapping map[string]any, parse common.ParseRuleFunc, makeBundleFile func(pathInBundle string) resource.BundleFile) (P.RuleProvider, error)

func SetTunnel

func SetTunnel(t P.Tunnel)

func UseLowMemoryMrsEncoder

func UseLowMemoryMrsEncoder()

Types

type ClashClassicalIndex

type ClashClassicalIndex struct {
	Bytes    []byte
	Rules    int
	Names    int
	IPRules  int
	Checksum uint32
}

func ClashCompileClassicalIndex

func ClashCompileClassicalIndex(lines []string, parse common.ParseRuleFunc) (ClashClassicalIndex, error)

type ClashCompiledSet

type ClashCompiledSet struct {
	Bytes  []byte
	SHA256 [sha256.Size]byte
	Count  int
}

func ClashCompileMappedDomainSet

func ClashCompileMappedDomainSet(lines []string) (ClashCompiledSet, error)

func ClashCompileMappedIPCidrSet

func ClashCompileMappedIPCidrSet(lines []string) (ClashCompiledSet, error)

func ClashMappedFromMrs

func ClashMappedFromMrs(mrs []byte, behavior P.RuleBehavior) (ClashCompiledSet, error)

type InlineProvider

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

func (InlineProvider) Initial

func (i InlineProvider) Initial() error

func (InlineProvider) LoadedMetadataJSON

func (i InlineProvider) LoadedMetadataJSON() ([]byte, error)

func (InlineProvider) MarshalJSON

func (i InlineProvider) MarshalJSON() ([]byte, error)

func (InlineProvider) Name

func (i InlineProvider) Name() string

func (InlineProvider) Update

func (i InlineProvider) Update() error

func (InlineProvider) VehicleType

func (i InlineProvider) VehicleType() P.VehicleType

type RulePayload

type RulePayload struct {
	/**
	key: Domain or IP Cidr
	value: Rule type or is empty
	*/
	Payload []string `yaml:"payload"`
	Rules   []string `yaml:"rules"`
}

type RuleSet

type RuleSet struct {
	common.Base
	// contains filtered or unexported fields
}

func NewRuleSet

func NewRuleSet(ruleProviderName string, adapter string, isSrc bool, noResolveIP bool) (*RuleSet, error)

func (*RuleSet) Adapter

func (rs *RuleSet) Adapter() string

func (*RuleSet) Match

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

func (*RuleSet) MatchDomain

func (rs *RuleSet) MatchDomain(domain string) bool

MatchDomain implements C.DomainMatcher

func (*RuleSet) MatchIp

func (rs *RuleSet) MatchIp(ip netip.Addr) bool

MatchIp implements C.IpMatcher

func (*RuleSet) Payload

func (rs *RuleSet) Payload() string

func (*RuleSet) ProviderNames

func (rs *RuleSet) ProviderNames() []string

func (*RuleSet) RuleType

func (rs *RuleSet) RuleType() C.RuleType

type RuleSetProvider

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

func (*RuleSetProvider) Close

func (rp *RuleSetProvider) Close() error

func (RuleSetProvider) Format

func (rp RuleSetProvider) Format() P.RuleFormat

func (RuleSetProvider) Initial

func (rp RuleSetProvider) Initial() error

func (RuleSetProvider) LoadDetached

func (rp RuleSetProvider) LoadDetached(buf []byte, updatedAt time.Time) error

func (RuleSetProvider) LoadedMetadataJSON

func (rp RuleSetProvider) LoadedMetadataJSON() ([]byte, error)

func (RuleSetProvider) MarshalJSON

func (rp RuleSetProvider) MarshalJSON() ([]byte, error)

func (RuleSetProvider) SideUpdate

func (rp RuleSetProvider) SideUpdate(payload []byte) error

func (RuleSetProvider) Update

func (rp RuleSetProvider) Update() error

Jump to

Keyboard shortcuts

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