Skip to content

rule-process ​

Rule conditions on the process behind a connection, as in sing-box 1.14.4: process_name, process_path, process_path_regex, user, user_id. The Android package_name and package_name_regex are declared so as to reject them with the error "only supported on Android".

Crateours-mod-rule-process, modules/routing/rule-process
Binary featurerule-process (part of rule-conditions)
Crate featuresnone

requires ​

router — the module extends its conditions point; without router there is nowhere to apply the conditions. The crate does not depend on ours-mod-router (only as a dev dependency): the link is by the point's name.

provides ​

Seven Provide::Condition(Entry { .. }) — variants of the conditions point. Each: the key in match, Group::Each (the condition is a group of its own), applies: EVERYWHERE (Place::Route and Place::Dns: route rules, DNS rules and rule-sets), a decoder and the value's schema.

Syntax: route.

Dependencies ​

ours-net-info (proc::executable_name and the process lookup), ours-api, ours-codec, ours-json, regex.

Design ​

src/lib.rs: Item implements ours_api::rules::Condition and matches the found process (paths, user, uid) against one of the kinds (Name, Path, PathRegex, User, UserId).

The process lookup itself is done by the dispatcher, and only when a rule needs it (RuleNeeds in router), and only for connections from the host's own addresses — as in sing-box.

Tests ​

modules/routing/rule-process/tests/rules.rs — the conditions in route rules, DNS rules and rule-sets through router.

GPL-3.0-or-later