Router
RouterConfig and RuleConfig
Routing is configured in ServerConfig.router (RouterConfig).
Schema definition: protos/proto/vx/router/router.proto.
Rules are evaluated in order; the first matching rule determines the outbound or selector. Subsequent rules are not considered after a match.
Examples
Route everything to direct:
{
"router": {
"rules": [
{ "matchAll": true, "outboundTag": "direct" }
]
}
}Route a specific inbound to a specific outbound:
{
"router": {
"rules": [
{
"inboundTags": ["trojan"],
"matchAll": true,
"outboundTag": "direct"
}
]
}
}RouterConfig
RuleConfig
Target: Exactly one of outboundTag and selectorTag must be set. If both are empty, the connection will be blocked.
outboundTagSend to this outbound handler
ruleNameName
Fallback
selectorTagFallback selector (mutually exclusive with outboundTag)
outboundTagFallback outbound (mutually exclusive with selectorTag)
lastIf the condition matches, this fallback is final and later fallbacks are not considered
Action
Fields for Fallback.action:
ipToDomainRewrite the IP back to a domain on fallback
Condition
Used in rule.condition or fallback.condition.
matchAllMatch all connections
usernamesMatch authenticated user IDs
srcCidrsSource IP match
srcIpTagsSource IP match using set names from Geo
dstCidrsDestination IP match
dstIpTagsDestination IP match using set names from Geo
resolveDomainResolve the domain; all IPs must be in dstIpTags or dstCidrs
resolveSoftRewriteResolve the domain; any IP in dstIpTags or dstCidrs matches, and rewrite the destination to that IP
resolveSoftNoRewriteResolve the domain; any IP in dstIpTags or dstCidrs matches, but do not rewrite the destination
networksTCP, UDP, etc.
protocolsProtocol sniffing results
ipv6Match IPv6 only
fakeIpMatch Fake IP destinations
skipSniffDisable sniffing for connections to IP destinations
inboundTagsMatch inbound tag
SelectorConfig
Selectors filter candidate nodes from a group of outbounds, then pick the node actually used for the connection according to a strategy. Defined in ClientConfig.selectors (SelectorsConfig); primarily used by the VX client. Router rules reference them via selectorTag.
For client UI behavior, see Selectors.
tagSelector name. Referenced by RuleConfig.selectorTag and Fallback.selectorTag.
strategyWhich nodes to actually use from the filtered pool:
ALL: All nodes in the poolALL_OK: All available nodes (falls back to untested nodes if none are available)LEAST_PING: Single node with lowest pingMOST_THROUGHPUT: Single node with highest speed-test throughputTOP_PING: All nodes within 30% of the lowest ping (e.g. lowest 100 ms → includes ≤ 130 ms)TOP_THROUGHPUT: All nodes with throughput ≥ 70% of the highest (e.g. highest 100 → includes ≥ 70)
Single-node strategies (LEAST_PING, MOST_THROUGHPUT) do not use balanceStrategy; multi-node strategies require load balancing.
balanceStrategyFor multi-node strategies, which node handles each connection:
RANDOM(default): Random choice from the active set; IPv6 connections prefer nodes that support IPv6MEMORY: Sticky reuse of the same node per app or root domain; assigns randomly on first use and remembers the mapping
selectFromOmOn the server, this should be true
speedTestSizeDownload bytes per speed test. When speedTestSizeRange is not set and this is 0, the core defaults to 1 MiB.
speedTestIntervalInterval for speed-testing filtered nodes (minutes). Only MOST_THROUGHPUT and TOP_THROUGHPUT run periodic speed tests.
pingTestIntervalInterval for pinging filtered nodes (minutes). Only LEAST_PING and TOP_PING run periodic pings.
unusableTestIntervalInterval for re-checking nodes marked unusable (minutes). All strategies except ALL check availability.
speedTestSizeRangeRandom range for speed-test download size (bytes). When 0 < min ≤ max, each test picks a random value in [min, max]; otherwise speedTestSize is used.
Filter
prefixesOutbound tag matches if it starts with any prefix
tagsOutbound tag matches if it equals any value in the list
subStringsOutbound tag matches if it contains any substring (database mode only)
inverseWhen true, invert: only outbounds that do not match prefixes / tags are included (outbound manager mode)
SpeedTestSizeRange
minLower bound for random speed-test size (bytes)
maxUpper bound for random speed-test size (bytes)
Related
- Geo —
domainTags,dstIpTags,geoDomains - DNS — Resolution for
resolveDomainrules - Dispatcher — Sniffing affects protocol/domain matching