Skip to content

parse the rules in Clash’s YAML files and provides optimized matching algorithms

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE
Notifications You must be signed in to change notification settings

e1732a364fed/clash_rules

Repository files navigation

Clash Rules   Latest Version

This project can parse the rules and rule-sets in Clash’s YAML configuration files and provides optimized blazingly fast matching algorithms.

The project uses functional programming.

DOMAIN-SUFFIX, IP-CIDR(6) uses radix trie, DOMAIN-KEYWORD uses Aho-Corasick Automaton. DOMAIN-REGEX uses RegexSet. PORT uses binary search.

In general the algorithms are about 40x times faster than the unoptimized ones. If the cpu supports simd, DOMAIN-KEYWORD can speed up about 80x.

You can run cargo bench to test how fast the algorithm is on your machine.

For examples, see the test at the end of the lib.rs and benches/algorithms.

There's a convenient struct ClashRuleMatcher and an enum Rule.

Also has feature to load and save to sqlite.

Supported rules are: RULE-SET, GEOSITE, AND, OR, NOT, DOMAIN, DOMAIN-KEYWORD, DOMAIN-SUFFIX, DOMAIN-REGEX, IP-CIDR, IP-CIDR6, GEOIP, PROCESS-NAME, NETWORK, DST-PORT, SRC-PORT, IN-PORT, MATCH

Use external crate geosite-rs to support GEOSITE.

About

parse the rules in Clash’s YAML files and provides optimized matching algorithms

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages