English
Rule conditions
Everything that can be written in match of route rules. How conditions combine and how logic is written is in Rules. Almost all conditions take one value or a list; a list means "any of".
Connection
| Condition | Matches if |
|---|---|
inbound | The connection came to one of these inbounds (by name) |
network | The network: tcp or udp; any other value is an error |
ip_version | The IP version of the destination: 4 or 6 |
auth_user | The user name the client logged in to the inbound with (the protocol's users) |
protocol | The protocol found by sniffing: tls, http, quic, dns, stun, bittorrent, dtls, ssh, rdp, ntp; any other value is an error |
client | The client found by sniffing (by its TLS or QUIC fingerprint) |
protocol, client and the domain conditions from sniffing work only after do: sniff, see Actions.
Destination
| Condition | Matches if |
|---|---|
domain | The destination domain equals one of the values |
domain_suffix | The domain ends with one of the values: example.org matches example.org and a.example.org |
domain_keyword | The domain contains a substring |
domain_regex | The domain matches a regular expression |
ip_cidr | The destination IP is in one of the subnets: 10.0.0.0/8, 2001:db8::/32, 1.2.3.4 |
ip_is_private | true: the destination IP is private (RFC 1918, loopback, link-local and the like) |
port | The destination port: 443 or [80, 443] |
port_range | A port range: "1000:2000", ":1024", "8000:" |
The destination domain is known if the client sent a domain itself, if the address was taken from the fakeip pool, if sniffing found the domain, or if dns.reverse_mapping is on and the address came from an answer of the built-in DNS. For a connection to a bare IP without any of these, domain conditions are false.
The destination IP is known if the client sent an IP, or after the action do: resolve.
Source
| Condition | Matches if |
|---|---|
source_ip_cidr | The source IP is in one of the subnets |
source_ip_is_private | true: the source IP is private |
source_port, source_port_range | The source port, like port and port_range |
source_mac_address | The source MAC address: aa:bb:cc:dd:ee:ff |
source_hostname | The source host name from a DHCP lease |
source_mac_address and source_hostname come from the neighbor table and DHCP lease files (route.dhcp_lease_files); they work for clients on the same network.
Local process
For connections opened by programs on the same machine (Linux):
| Condition | Matches if |
|---|---|
process_name | The name of the process's executable |
process_path | The full path to the executable |
process_path_regex | The path matches a regular expression |
user | The name of the user the process runs as |
user_id | The UID of the process |
Host
| Condition | Matches if |
|---|---|
network_type | The type of the current default network: wifi, cellular, ethernet, other |
Rule-sets
| Condition | Matches if |
|---|---|
rule_set | At least one rule of one of the named rule-sets matched |
rule_set_ip_cidr_match_source | true: the ip_cidr conditions inside the rule-sets check the source IP, not the destination |
geoip, geosite | A shorthand: geoip: ru is rule_set: geoip-ru, geosite: google is rule_set: geosite-google; source_geoip has no such shorthand and is an error |
There are no built-in GeoIP and GeoSite databases: a rule-set with the corresponding name has to be declared in rule_sets, from an .srs or from a code of a V2Ray/Xray geosite.dat/geoip.dat database (the dat format). A missing rule-set is a load error:
yaml
rule_sets:
geosite-google:
remote: https://example.org/geosite-google.srs
route:
rules:
- match:
geosite: google
to:
outbound: proxy
final:
outbound: directNot supported
These sing-box conditions are known, but a configuration with them does not load: check and run end with an error giving the reason:
| Condition | Why |
|---|---|
wifi_ssid, wifi_bssid | Wi-Fi state is available only on Android, Apple and Windows |
network_is_expensive, network_is_constrained | The system does not report metered networks |
package_name, package_name_regex | Android only |
clash_mode | There is no Clash API |
interface_address, network_interface_address, default_interface_address | Not supported |
preferred_by | Not supported |
The fields invert, type, mode, rules are an error: logic is written with the any, all, not nodes.