Skip to content

Routing and rules ​

Ours: the syntax — modules/routing/router/src/syntax.rs, building conditions — modules/routing/router/src/lib.rs (default, unsupported), actions — the same place (action), rule-sets — rule_set.rs, remote.rs; process conditions — modules/routing/rule-process. The reference: option/rule.go, option/rule_action.go, route/rule/* of sing-box v1.14.4.

route rule conditions ​

All fields of v1.14.4's option/rule.go are decoded; the refusal comes when the rule is built (parse rule[N]: …).

WhatStatusWhereVerdict
wifi_ssid, wifi_bssidnorouter/src/lib.rs (unsupported)platform (Android/Apple/Windows); on Linux possible through NetworkManager/iwd — rarely needed
network_is_expensive, network_is_constrainednothe same placeplatform
package_name, package_name_regexnomodules/routing/rule-process/src/lib.rsplatform (Android)
clash_modenorouter/src/lib.rsjunk while there is no Clash API (see other.md)
interface_address, network_interface_address, default_interface_addressnothe same placemissing: interface addresses are already read by crates/runtime/src/host.rs
preferred_byno: not implemented yetthe same placemissing
geoip, source_geoip, geosite as databasesdifferent: a shorthand for the rule-sets geoip-<x>/geosite-<x>; the .dat databases themselves are read as rule-sets of the dat formatrouter/src/syntax.rs (conditions), router/src/dat.rs— (in sing-box the databases were removed in 1.12)
rule_set_ipcidr_match_source (the old name)no, as in the referencerouter/src/lib.rsjunk
user, user_id, process_*present (Linux, through inet_diag/procfs)modules/routing/rule-process—
dns_server_address, dns_search_domain (also in dns.rules)no: unknown field— (not decoded)missing
source_mac_address, source_hostnamepresent (neighbours and DHCP leases)router/src/item.rs—

Actions ​

WhatStatusWhereVerdict
route with route-options: tls.fragment, tls.spoof (in sing-box tls_fragment*, tls_record_fragment, tls_spoof*)no: …: not implemented yetrouter/src/lib.rs (route_options)missing: fragmentation already exists in the outbound's tls block, it needs to be carried from the rule
resolve.serverdifferent: forbidden in YAML, the server is chosen by dns.rules with outboundrouter/src/syntax.rs (do_action)— (design)
reject replypresent: for TCP/UDP an error, as in the referencemodules/system/dispatch/src/lib.rs—
reject.no_dropno: not in YAML, always falserouter/src/syntax.rs (reject)rarely needed
bypass without an outbound in the processdifferent: the rule is skipped and checking goes on; with final: bypass the connection goes to a synthetic direct named bypasscrates/api/src/route.rs (Action::Bypass { outbound: None }), crates/native-config/src/rules.rs (Final::Bypass)—
bypass with an outboundno: unavailable from YAMLrouter/src/syntax.rs (target)rarely needed
hijack-dns, sniff, resolve, route-optionspresent——

route ​

WhatStatusWhereVerdict
route.dial.interfaces.strategy and others without auto_detect_interface/route.dial.interfaceno: refused at build timecrates/kernel/src/instance.rs (reject_unimplemented)— (as in the reference on platforms without a monitor)
tcp_half_close_timeoutbeyond the reference: a half-closed TCP connection is closed after the remaining direction has been idle (60 s by default); the reference waits for the other side to close forevercrates/relay/src/lib.rs (relay_stream_ended), crates/api/src/dispatch.rs (HALF_CLOSE_TIMEOUT)—
default_domain_resolver, rule_set, geoip, geositedifferent (design)crates/native-config/src/rules.rs—

Rule-sets ​

WhatStatusWhereVerdict
Conditions inside a set: package_name*, wifi_*, network_is_*, network_interface_address, default_interface_addressno (inline and binary)router/src/rule_set.rs (unsupported, binary_default)see the route rule conditions
AdGuard rules in .srspresent (ITEM_ADGUARD_DOMAIN)libs/srs/src/binary.rs, router/src/rule_set.rs—
http_client with dial options other than detournorouter/src/remote.rs (download_client)missing
http_client HTTP/2, HTTP/3 without fallbackno: always HTTP/1.1the same placemissing
http_client.engine: applenothe same place (http_client)platform
download_detour (the old name)different: in YAML it is viarouter/src/syntax.rs (remote_rule_set)—
The source format with rule versionspresentrouter/src/options (parse_rule_set)—

Xray ​

WhatStatusVerdict
domainStrategy: IPIfNonMatch/IPOnDemanddifferent: do: resolve at the right place in the list—
geosite:/geoip: with .datdifferent: geosite.dat/geoip.dat are rule-sets of format: dat with a category in Xray syntax (cn, google@cn, !cn), matched by the rule-set engine; a rule refers to them with rule_set or with geosite:/geoip: by the set's name, there is no ext:file:code—
domainMatcher: mphdifferent: domains are in a succinct trie, as for .srs— (design)
geosite:/geoip: in rules from Xray subscriptionsno: subscriptions give only servers, routing rules are not imported—
The attrs conditions, user by emailno; auth_user — by user namerarely needed
Balancers, observatorydifferent: groups—

GPL-3.0-or-later