8. Providers and Policy Groups#


Providers are responsible for “obtaining nodes or rules in batches”; policy groups are responsible for “selecting one or more exits from multiple nodes”.

Outbound Node Sources#

SourceConfigurationSuitable Scenarios
Static nodesproxiesA small number of fixed nodes, manual configuration
Proxy providerproxy-providersSubscriptions, files, inline nodes, WARP dynamic nodes
Built-in nodesDIRECT, REJECTDirect connection and rejection

proxy-providers#

HTTP Subscription#

proxy-providers:
  airport:
    type: http
    format: auto
    url: https://example.com/sub.yaml
    path: ./providers/airport.yaml
    interval: 3600
    proxy: DIRECT
    header:
      User-Agent:
        - Link1
    filter: '香港|日本|新加坡'
    exclude-filter: '倍率:10|过期'
    exclude-type: direct
    size-limit: 10485760
    health-check:
      enable: true
      url: http://www.gstatic.com/generate_204
      interval: 300
      timeout: 5000
      expected-status: 204

Local File#

proxy-providers:
  local:
    type: file
    path: ./providers/local.yaml
    format: mihomo

Inline Payload#

proxy-providers:
  inline-nodes:
    type: inline
    payload:
      - name: local-socks
        type: socks5
        server: 127.0.0.1
        port: 1080

WARP provider#

proxy-providers:
  warp:
    type: warp
    mode: auto
    transports:
      - wireguard
      - masque

The warp provider materializes WARP exit nodes. Do not write type: warp under proxies.

Why WARP is a provider: the same WARP state may generate two types of outbound nodes, wireguard and masque, and auto mode needs to persist the account, keys, endpoint, and transport state. By placing it in a provider, policy groups can use these materialized results just like subscription nodes, for example use: [warp]. For detailed fields and mechanisms, see Outbound Protocol Configuration: WARP provider.

proxy-provider Fields#

FieldMeaningActual Effect
typehttp, file, inline, warpDetermines provider behavior
formatauto, mihomo, uri, base64, sip008, surge, quanx, sing-boxDetermines how subscription content is parsed
pathLocal pathHTTP cache or file read
urlSubscription URLUsed by type=http
intervalRefresh interval, in secondsControls automatic refresh
dialer-proxy / proxyExit used to fetch the subscriptionUsed when the subscription is blocked or is on an intranet
filterRegex for node names to keepFilters nodes
exclude-filterRegex for node names to excludeRemoves invalid, high-multiplier, or expired nodes
exclude-typeProtocol types to excludeFor example, exclude ssr or direct
headerHTTP request headersSubscription authentication or UA
size-limitResponse size limitPrevents abnormally large subscriptions
health-checkProvider-level health checkEstablishes probe state for provider nodes
overrideBatch override node fieldsUniformly sets UDP, certificate verification, prefixes, etc.
payloadInline node listUsed by type=inline

provider override#

proxy-providers:
  airport:
    type: http
    url: https://example.com/sub.yaml
    path: ./providers/airport.yaml
    override:
      skip-cert-verify: true
      udp: true
      down: 200 Mbps
      up: 50 Mbps
      dialer-proxy: DIRECT
      interface-name: eth0
      routing-mark: 100
      ip-version: ipv4-prefer
      additional-prefix: '机场 - '
      additional-suffix: ' - 自动'
      proxy-name:
        - pattern: 'United States'
          target: 'US'

Actual effects:

Policy Group Types#

A policy group is not a new outbound protocol. It only answers two questions:

  1. Which member is ultimately selected for this traffic? For example, select, url-test, smart, fallback, load-balance.
  1. Should this traffic pass through multiple members in order? For example, relay.

Policy group members can come from three types of sources:

When loading the configuration, Link1 first resolves members, then deduplicates, filters, and checks for circular references. A group can reference another group, but it cannot form a cycle such as A -> B -> A. Health-checking policy groups expand nested groups to leaf nodes for probing, avoiding probes that only reach the “group” wrapper.

proxy-groups:
  - name: PROXY
    type: select
    proxies:
      - AUTO
      - DIRECT

  - name: AUTO
    type: url-test
    use:
      - airport
    url: http://www.gstatic.com/generate_204
    interval: 300
    timeout: 5000
TypeBehaviorSuitable ScenariosKey Notes
selectUser manually selects one memberPrimary exit that needs controllable switchingThe selection is a member name; the member can be either a node or a group.
url-testSelects a better member based on probe latencyAutomatically choosing the best among multiple nodes in the same regionMainly relies on health check results.
smartDynamically ranks members using both health probes and real dialing feedbackAutomated primary exit, long-running routersDoes not only look at speed tests; it also learns failure rate, jitter, and real connection behavior.
fallbackSelects the first available member in orderPrimary/backup linksMember order is priority.
load-balanceDistributes connections across multiple membersBalanced use of multiple nodesstrategy determines round-robin, hashing, or sticky sessions.
relayBuilds a multi-hop chain in orderUpstream proxy, jump chains, chained exitsMember order is the chain order, and compatibility requirements are stricter than normal groups.

If you only want “Link1 to automatically select a good node”, start with smart or url-test; use relay only when you explicitly need “go through A first, connect from A to B, and finally exit from B”.

select: Manual Selection#

select is the easiest policy group to understand: it presents multiple members to the user, and the user or App selects the current member. It does not actively run speed tests and will not switch automatically, making it suitable as a top-level entry point.

proxy-groups:
  - name: PROXY
    type: select
    proxies:
      - SMART
      - JP
      - US
      - DIRECT

Actual effect: when a rule uses PROXY, traffic goes through the member currently selected in PROXY. If the selected member is another group, such as SMART, Link1 continues to apply SMART’s selection logic.

url-test: Automatic Selection by Probe Latency#

url-test periodically makes each candidate node access url, records latency and availability, and then selects the item with the lowest latency.

proxy-groups:
  - name: JP-AUTO
    type: url-test
    use: [airport]
    filter: '日本`JP`Tokyo'
    url: http://www.gstatic.com/generate_204
    interval: 300
    timeout: 5000
    tolerance: 50

Field effects:

smart: Health Probes + Real Dialing Feedback#

smart can be understood as an enhanced url-test. It also uses url, interval, timeout, and tolerance to build a basic health ranking, but it does not rely only on speed tests. After real service connections occur, it also records each candidate’s success rate, real dialing time, and jitter, and uses this feedback to fine-tune the ranking.

proxy-groups:
  - name: SMART
    type: smart
    use: [airport]
    filter: '香港`日本`新加坡'
    exclude-filter: '过期`倍率:10'
    url: http://www.gstatic.com/generate_204
    interval: 300
    timeout: 5000
    tolerance: 80
    lazy: true

How smart works:

  1. Check health status first: healthy nodes rank before unknown nodes; nodes known to be unavailable are not tried first.
  1. Then consider real feedback: successful real connections record latency; failures record failure signals and may trigger a health probe for that node.
  1. Limited concurrent attempts: when dialing, candidates are tried according to the current ranking. Later candidates are only tried in a staggered manner if the previous candidate takes too long to produce a result, avoiding hitting all nodes at once.
  1. Failure gating: if a candidate has recently had an excessive failure rate, it is moved further back.
  1. Limited exploration: during long-term operation, suboptimal candidates are periodically given a chance, preventing recovered nodes from being permanently suppressed by old data.
  1. Manual selection can override: if the App temporarily pins a member, smart uses it first. When it is determined to be unhealthy or dialing fails, the pinned selection is cleared and automatic ranking resumes.

Differences between smart and url-test:

Comparisonurl-testsmart
Decision basisMainly the latency and status of the probe URLProbe results + real dialing success rate/latency/jitter
Failure awarenessWaits for the next probe cycle to discover failuresService dialing failures immediately become feedback and can trigger a single-node probe
Suitable scenariosSelecting the lowest latency among homogeneous nodesLong-running setups, fluctuating node quality, unattended routers
ExplainabilitySimple and easy to predictSmarter, but short-term ranking changes with real connection feedback

Tuning suggestions:

fallback: Ordered Primary/Backup#

fallback is suitable for scenarios where “the primary node is preferred, and the backup is used only if the primary fails.” It looks for an available item in member order and does not try to minimize latency.

proxy-groups:
  - name: BACKUP
    type: fallback
    proxies:
      - hk-primary
      - jp-backup
      - DIRECT
    url: http://www.gstatic.com/generate_204
    interval: 300

Note: putting DIRECT at the end means “fall back to direct connection when all proxies are unavailable.” This may be useful for normal browsing, but may be unsuitable for traffic that requires privacy or a fixed exit.

load-balance: Distribute Connections#

load-balance distributes connections across multiple candidates and supports three strategy values:

strategyBehaviorSuitable Scenarios
round-robinPolls candidates in orderYou want to use multiple nodes evenly.
consistent-hashingHashes based on the target domain/IP, tending to use the same exit for the same targetReduces frequent exit changes for the same website.
sticky-sessionsMaintains stickiness for a period based on process name + targetLogin-sensitive applications, or client sessions that require a stable exit.
proxy-groups:
  - name: BALANCE
    type: load-balance
    use: [airport]
    filter: '香港`HK'
    strategy: consistent-hashing

relay: Chain Multiple Hops in Order#

relay does not “automatically select one node”; instead, it “chains multiple outbounds in order.” For example: first connect to a transit node through a local upstream proxy, then let the transit node connect to the final exit.

proxies:
  - name: front-node
    type: socks5
    server: 127.0.0.1
    port: 1080

  - name: exit-node
    type: ss
    server: exit.example.com
    port: 8388
    cipher: aes-128-gcm
    password: secret

proxy-groups:
  - name: RELAY
    type: relay
    proxies:
      - front-node
      - exit-node

This chain can be read as:

Client traffic -> Link1 -> front-node -> exit-node -> target website

Key rules for relay:

Common patterns:

GoalRecommended ConfigurationDescription
Connect to a remote node through a local proxy firstrelay: [local-socks, remote-node]A local proxy already exists on the machine, or there is an enterprise intranet jump host.
Select a transit first, then use a fixed exitrelay: [SMART-FRONT, exit-node]SMART-FRONT automatically selects the transit, while the exit remains fixed.
Both segments automaticrelay: [SMART-FRONT, SMART-EXIT]This can work, but troubleshooting is complex; verify the two groups separately first.

Policy Group Fields#

FieldMeaningActual Effect
nameGroup nameCan be referenced by rules or other groups, and must be unique.
typeGroup typeDetermines selection logic or chaining logic.
proxiesStatic member listCan reference nodes or other groups; order has real effects for fallback, relay, and round-robin.
useReferenced providersAdds nodes produced by providers to the group.
urlHealth check URLUsed by url-test/fallback/smart/load-balance.
intervalProbe interval, in secondsDefault is 300 seconds; shorter intervals are more responsive but consume more resources.
timeoutProbe timeout, in millisecondsDefault is 5000 ms; setting it too short on slow networks can cause false failures.
lazyLazy probingProbes only when needed, suitable for large subscriptions.
max-failed-timesCompatibility fieldNot recommended to rely on; actual availability is mainly determined by health probes and quality feedback.
disable-udpDisable group UDPEven if members support UDP, the group hides or rejects UDP capability externally.
interface-nameCompatibility fieldNot recommended to rely on for normal groups; preferably set the outbound interface on specific outbound nodes or globally. A relay chain respects socket options on the root node.
routing-markCompatibility fieldNot recommended to rely on for normal groups; preferably set Linux mark on specific outbound nodes or globally.
include-allInclude all static and provider nodesQuickly creates a group.
include-all-proxiesInclude all static nodesExcludes providers.
include-all-providersInclude all provider nodesExcludes static nodes.
filterMember name filterMultiple patterns can be separated by backticks; matching items are kept first.
exclude-filterMember name exclusionExcludes matching items after members are collected.
exclude-typeProtocol type exclusionFor example, exclude direct, ssr.
expected-statusExpected probe status codeUsed together with url to determine whether a probe succeeds.
health-checkNested health check configurationCan override url/interval/timeout/lazy/expected-status.
hiddenApp hiding hintAffects App display, but does not change forwarding logic.
iconApp iconAffects App display, but does not change forwarding logic.
toleranceLatency tolerance, in millisecondsUsed by url-test/smart to reduce switching caused by small latency jitter.
strategyload-balance strategyround-robin, consistent-hashing, sticky-sessions.

Member Sources and Filtering#

proxy-groups:
  - name: JP
    type: url-test
    include-all: true
    filter: '日本`JP`Tokyo'
    exclude-filter: '过期`倍率:10'
    exclude-type: ssr

Actual effects:

Health Checks#

Health check configuration can be written at the group top level or under health-check:

proxy-groups:
  - name: AUTO
    type: url-test
    use: [airport]
    health-check:
      url: http://www.gstatic.com/generate_204
      interval: 300
      timeout: 5000
      lazy: false
      expected-status: 204

Groups that support active health checks: url-test, smart, fallback, load-balance.

Groups that do not actively run health checks: select, relay.

Default values:

| Item | Default | | -- | ---- | | URL | http://www.gstatic.com/generate_204 | | interval | 300 seconds | | timeout | 5000 milliseconds |

Common Policy Group Templates#

Manual Primary Exit + Automatic Speed Test#

proxy-groups:
  - name: PROXY
    type: select
    proxies:
      - AUTO
      - DIRECT

  - name: AUTO
    type: url-test
    use: [airport]
    interval: 300

Primary/Backup fallback#

proxy-groups:
  - name: BACKUP
    type: fallback
    proxies:
      - node-primary
      - node-backup
      - DIRECT

Multi-hop relay#

proxy-groups:
  - name: RELAY
    type: relay
    proxies:
      - front-node
      - exit-node

Note: relay increases latency and failure points. Use it only when you explicitly need chained proxies.