Conditions

Reference for the RCX condition language: grammar, fields, functions, three-valued logic and limits.

On this page

Where conditions appear

ContextKindMay use
pool.include, pool.exclude, prefer[].when, chips, scenario programsServerServer and network fields, tag(), passes(), fails()
tags valuesServerServer and network fields, passes(), fails(); no tag()
network.kinds[].when, direct-splitNetworkNetwork fields and <diagnostic> ok or fail only; a server field fails with is about a server, not the network

An empty condition is always true.

Grammar

text
condition  = or
or         = and { "or" and }
and        = unary { "and" unary }
unary      = "not" unary | "(" or ")" | predicate
predicate  = boolfield
           | strfield ( "=" | "!=" ) value
           | strfield "in" "[" value { "," value } "]"
           | strfield "~" ( regex | string )
           | "latency" ( "=" | "!=" | "<" | "<=" | ">" | ">=" ) number
           | ( "tag" | "passes" | "fails" ) "(" name ")"
           | diagnostic ( "ok" | "fail" )
value      = word | string
word       = { letter | digit | "_" | "-" | "." | ":" }
string     = "'" { any but "'" } "'" | '"' { any but '"' } '"'
regex      = "/" { any, "\/" for a slash } "/" [ "i" ]
number     = digits [ "ms" ]
  • Keywords (and, or, not, in, ok, fail) and field names are case-insensitive. not binds tightest, then and, then or.

  • A lone ! is an error: use 'not' instead of '!'.

  • Strings have no escapes; quote any value with spaces, emoji or other characters outside word.

  • A regex is RE2, unanchored; i is the only flag. A quoted string after ~ is also read as a pattern.

  • String comparisons with =, != and in ignore case.

Fields

Server fields

FieldTypeValueUnknown when
namestringMember namenever
providerstringProxy provider that serves the membernever
typestringmihomo adapter type, such as Vless or Shadowsocksnever
serverstringServer host or addressnever
countrycountryVerified exit country, else the country in the name (flag or English name)never; empty counts as known
exit.countrycountryVerified exit countrynot verified yet
entry.countrycountryGeoIP country of server when it is an IP addressserver is a name or not in the database
udpbooleanMember supports UDPnever
alivebooleanHealth alivenever
deadbooleanHealth deadnever
measuredbooleanHas latency samples from the last 6 hoursnever
currentbooleanIs the selected membernever
latencynumber, msMedian latencynever; comparisons are false while not measured

Country values are ISO 3166-1 alpha-2 codes (NL, DE).

Network fields

FieldTypeValue
network.kindstringThe confirmed network kind
network.transportstringwifi, ethernet, cellular or other on Android
network.portalbooleanThe system reports a captive portal
meteredbooleanThe network is metered

Network fields are unknown until the platform reports the network; network.kind is unknown until a kind is confirmed.

Functions

FormTrue whenErrors
tag(name)The tag's condition is definitely true for the member; unknown counts as false.unknown tag; tag(…) is not allowed here
passes(id)The last result of check id is a pass.unknown check
fails(id)The last result of check id is a hard failure.unknown check
<diagnostic> okAny target of the diagnostic answered.<name> needs ok or fail
<diagnostic> failEvery target was tried and none answered.

A check that was never run is unknown. A failed optional check makes both passes() and fails() false. A pass flips only after two consecutive failures; see Evidence.

Three-valued logic

Each predicate is true, false or unknown, combined by Kleene logic.

ABA and BA or Bnot A
trueunknownunknowntruefalse
falseunknownfalseunknowntrue
unknownunknownunknownunknownunknown

Consequences:

  • A tier counts a member only when its condition is true. Unknown makes the member pending, which the planner may check.

  • pool.include admits unknown; pool.exclude removes only true.

  • An unknown network kind rule stops recognition until it resolves.

Limits

ItemLimit
Condition length2048 characters
Nesting16 levels; each not and each parenthesis adds one
Regex length512 characters

Examples

ConditionMeaning
not deadAny member not marked dead
country in [NL, DE] and latency < 120msDutch or German, measured under 120 ms
exit.country != RU and passes(open)Verified non-RU exit that opens the check
name ~ /premium/iName contains premium in any case
name ~ '⚡ RU'Name contains the literal text ⚡ RU
udp and not type = HttpSupports UDP and is not an HTTP proxy
metered or network.transport = cellularNetwork condition: metered or mobile data
home ok and foreign failNetwork condition: only the home diagnostic answers

Searches every section: providers and RCX