[Proxy Group] Policy Groups
This section configures proxy policy groups, aggregating multiple target servers and supporting scheduling policies such as manual selection, latency testing, failover, load balancing, and network environment matching.
Syntax Declaration
Policy groups are declared using standard INI configuration lines:
name = type, member1, member2, ..., [options...]Component breakdown:
name: Unique identifier for the policy group, referenced by routing rules in[Rule]or parent policy groups.type: Scheduling policy type (case-insensitive), supportingselect,url-test(aliasurltest),fallback,load-balance(aliasloadbalance), andsubnet.member1, member2, ...: List of candidate members. Members can be:- Named proxy servers declared in
[Proxy]; - Built-in action policies (e.g.,
DIRECT,REJECT,REJECT-DROP); - Other policy group names (enabling multi-level nesting and cascading).
- Named proxy servers declared in
[options...]: Key-value options (key=value) for configuring external resource inclusion (includes), health check intervals (check-interval), latency switching tolerance (tolerance), load balancing algorithms (algorithm), etc.
subnet Type Syntax
For subnet policy groups, candidate outbounds are determined by network matching conditions rather than positional member lists:
name = subnet, default=outbound_name, condition1=outbound1, condition2=outbound2, ...Policy Group Types Overview
| Declaration Type | Scheduling Mode | Notes |
|---|---|---|
select | Manual Selection | |
url-test | Auto Speed Test | Compatible alias urltest |
fallback | Failover | |
load-balance | Load Balancing | Compatible alias loadbalance |
subnet | Network Environment Matching |
Common Options
Except for subnet, all policy groups support the following common options:
includes(List of resource names, default empty list) Applicable types: All (exceptsubnet). Imports external proxy resources defined in Proxy Resource; multiple names use[...]list syntax (a single name without commas may use the shorthandincludes=RemoteNodes).iniincludes=RemoteNodes includes=[RemoteNodes, BackupNodes]include-local(Boolean, defaultfalse) Imports all nodes from the current profile's[Proxy]section, excluding other policy groups and built-in outbounds (DIRECT,REJECT, and its variants).filter(Regular expression, no filtering by default; aliasregex-filter) Filters members imported through bothincludesandinclude-localby node name. Explicit positional members are always retained. The same expression applies after subscription updates. Invalid expressions fail profile parsing.iniRegional = select, DIRECT, include-local=true, includes=RemoteNodes, filter="^(US|HK)"Members are ordered as explicit members, imported local nodes, then resource nodes, with duplicate names removed. When nothing matches, only explicit members remain.
check-interval(Positive integer, unit: seconds, default300) Applicable types:url-test,fallback,load-balance. Interval for health checks and latency probing.inicheck-interval=300max-preferred-latency(Positive integer, unit: milliseconds, unset) Applicable types:fallback,load-balance. When healthy members with latency at or below this value exist, members above it are temporarily excluded from this group's candidates. If all healthy members exceed it, selection still uses those healthy members. This option only affects candidates in this group; it does not change node health or affect other groups.inimax-preferred-latency=800
Policy Group Types & Specific Options
select Manual Selection
select policy groups allow explicit external selection of the active member:
name = select, member1, member2, ..., [includes=Resource1 | includes=[Resource1, Resource2]]In addition to explicitly listed positional members, external nodes imported via includes are added as candidate members.
[Proxy Group]
Proxy = select, AutoTest, DirectOut, Node-A, Node-B, includes=[RemoteNodes, BackupNodes]
SingleResourceProxy = select, DirectOut, includes=RemoteNodes
[Proxy Resource]
RemoteNodes = https://subscribe.example.com/main.conf
BackupNodes = https://subscribe.example.com/backup.confurl-test Auto Speed Test
Probes candidate node latencies concurrently and automatically selects the available node with the lowest latency:
tolerance(Unsigned integer, unit: seconds, default0) Avoids frequent switching caused by small latency changes. When the current node is available, switching occurs only when the new node is faster by more than the configured duration.initolerance=1
Probing and Switching Mechanism
- Probe Target Resolution: The probe URL prioritizes the candidate node's own
override-test-url; if not set, it inherits the globalproxy-test-urlfrom[General]. - Tolerance Mechanism: With
tolerance=1, if the current node takes 1.5 seconds and the new node takes 0.8 seconds, the 0.7-second improvement is not enough to switch. If the new node takes 0.4 seconds, the 1.1-second improvement triggers a switch. When the current node is unavailable, the tolerance does not apply.
[Proxy Group]
AutoTest = url-test, NodeA, NodeB, NodeC, check-interval=180, tolerance=1fallback Failover
fallback policy groups select the first member, in configuration order, from the candidates that are healthy and meet this group's latency filter. When the current member no longer meets these conditions, another qualifying member is selected.
[Proxy Group]
HighAvailability = fallback, PrimaryNode, BackupNode, DIRECT, check-interval=60, max-preferred-latency=800load-balance Load Balancing
load-balance policy groups distribute connections across healthy members:
algorithm(Enum, defaultpcc) Connection distribution algorithm:pcc/0/consistent-hash,random/1,round-robin/2. See details below.inialgorithm=consistent-hashweights(Ordered key-value map from regular expressions to integer weights, default empty) Matches node names in configuration order, with the first matching rule taking effect; unset or unmatched nodes receive weight1. Rules apply to explicit members, members imported viainclude-local, and members imported viaincludes, and are re-evaluated when subscription members update.Uses
{pattern=weight, ...}ordered key-value syntax: keys are regular expressions (enclose in double quotes when containing special characters or whitespace), and values must be unquoted integers up to4294967295; integers less than1are treated as1. Quoted weight values, decimals, non-integers, duplicate regex keys, invalid regular expressions, or out-of-range values fail configuration validation. Regular expressions match anywhere in the name unless anchored with^and$; backslashes inside double-quoted patterns follow double-quoted string escaping (for example,"^HK-\\d+$"corresponds to regex^HK-\d+$).iniweights={"HK|HongKong"=3, "JP|Japan"=2, ".*"=1}Each matching node receives the assigned weight individually. For example, with 10 Hong Kong nodes weighted
3and 2 Japan nodes weighted2, their combined weight ratio is30:4. Weights affect selection share and do not guarantee exact byte-volume ratios.
Scheduling Algorithms
pcc(consistent-hash): Consistent Hashing. Computes a hash from the destination registrable domain or destination IP and maps it onto the cumulative weight intervals of candidate members. When candidates, order, and weights remain unchanged, identical destinations route to the same member; changes to members or weights may remap destinations. Weights represent shares of the destination hash space rather than connection-count ratios.random: Weighted Random Distribution. Selects a candidate with probability equal to its weight divided by the total candidate weight.round-robin: Smooth Weighted Round-Robin. Adds each candidate's weight to its running score, picks the candidate with the highest score, and subtracts the total weight from that candidate's score; ties break by member order. When all weights are1, this reduces to sequential round-robin by member order.
Health and max-preferred-latency filters are applied before selecting from the remaining candidates' weights. When no healthy members exist, selection falls back to the first member; if the member list is empty, no outbound is available. An explicit Pin overrides automatic selection. Member weights are computed and cached when the member list updates, while cumulative intervals and total weight are updated on candidate refresh; no regex matching or total-weight recomputation occurs per connection. Refreshes with unchanged candidates preserve round-robin state.
[Proxy Group]
LoadBalanced = load-balance, NodeA, NodeB, NodeC, algorithm=pcc, check-interval=120, max-preferred-latency=600
Weighted = load-balance, includes=Subscription, algorithm=round-robin, weights={"HK|HongKong"=3, "JP|Japan"=1}subnet Network Environment Matching
Selects network outbounds based on current network attributes (Wi-Fi SSID, BSSID, interface type, or gateway address):
default(Proxy or policy group name, required) Default outbound when the current network matches no conditions.inidefault=ProxyGroupCondition mapping keys (format
prefix:pattern = target_name, unset) Mapping rules between network environments and target outbounds; multiple rules can be declared.iniSSID:HomeWiFi=DIRECT
Network Matching Prefixes
Prefixes are case-insensitive and support the following matching dimensions:
SSID:name: Matches the connected Wi-Fi network name (SSID). Keys without a prefix default to SSID matching.BSSID:mac: Matches the MAC address of the connected wireless AP.TYPE:type: Matches the system network media type (e.g.,WIFI,CELLULAR).GATEWAY:ip: Matches the default gateway IP address of the active network interface.
[Proxy Group]
AutoNetwork = subnet, default=ProxyGroup, SSID:HomeWiFi=DIRECT, SSID:OfficeCorp=OfficeGateway, TYPE:CELLULAR=DIRECTConfiguration Examples
Basic Configuration
[Proxy Group]
# 1. Manual select group
FinalProxy = select, AutoTest, FallbackGroup, LoadBalancedGroup, DIRECT
# 2. Auto speed-test group
AutoTest = url-test, includes=[RemoteNodes, BackupNodes], check-interval=300, tolerance=1
# 3. Failover group
FallbackGroup = fallback, PrimaryNode, BackupNode, DIRECT, check-interval=60, max-preferred-latency=500
# 4. Load-balancing group
LoadBalancedGroup = load-balance, NodeA, NodeB, NodeC, algorithm=consistent-hash, check-interval=180
# 5. Subnet environment matching group
OfficeAware = subnet, default=FinalProxy, SSID:OfficeWiFi=DIRECT, TYPE:CELLULAR=FinalProxy