Struct ClashRuleMatcher

Source
pub struct ClashRuleMatcher {
    pub domain_target_map: Option<HashMap<String, String>>,
    pub domain_keyword_matcher: Option<DomainKeywordMatcher>,
    pub domain_suffix_matcher: Option<DomainSuffixMatcher>,
    pub domain_regex_set: Option<HashMap<String, RegexSet>>,
    pub ip4_matcher: Option<IpMatcher>,
    pub ip6_matcher: Option<Ip6Matcher>,
    pub mmdb_reader: Option<Arc<Reader<Vec<u8>>>>,
    pub country_target_map: Option<HashMap<String, String>>,
    pub rules: Vec<(Rule, String)>,
}
Expand description

convenient struct for checking all rules. init mmdb_reader using maxminddb::Reader::from_source

Fields§

§domain_target_map: Option<HashMap<String, String>>§domain_keyword_matcher: Option<DomainKeywordMatcher>§domain_suffix_matcher: Option<DomainSuffixMatcher>§domain_regex_set: Option<HashMap<String, RegexSet>>§ip4_matcher: Option<IpMatcher>§ip6_matcher: Option<Ip6Matcher>§mmdb_reader: Option<Arc<Reader<Vec<u8>>>>

for GEOIP

§country_target_map: Option<HashMap<String, String>>

for GEOIP

§rules: Vec<(Rule, String)>

stores un-optimized left rules, which are AND,OR,NOT,PROCESS-NAME, DST-PORT, NETWORK,MATCH

(rule, target)

Implementations§

Source§

impl ClashRuleMatcher

Source

pub fn from_hashmap( method_rules_map: HashMap<String, Vec<Vec<String>>>, ) -> Result<Self, ParseRuleError>

Source

pub fn from_clash_config_str(cs: &str) -> Result<Self, Box<dyn Error>>

Source

pub fn from_clash_config_file<P: AsRef<Path>>( path: P, ) -> Result<Self, Box<dyn Error>>

Source

pub fn check_ip4(&self, ip: Ipv4Addr) -> Option<&String>

Source

pub fn check_ip6(&self, ip: Ipv6Addr) -> Option<&String>

Source

pub fn check_ip(&self, ip: IpAddr) -> Option<&String>

Source

pub fn check_ip_country_iso(&self, ip: IpAddr) -> &str

Source

pub fn check_ip_country(&self, ip: IpAddr) -> Option<&String>

Source

pub fn check_domain(&self, domain: &str) -> Option<&String>

Trait Implementations§

Source§

impl Debug for ClashRuleMatcher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClashRuleMatcher

Source§

fn default() -> ClashRuleMatcher

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.