Skip to content

subscriptions — subscriptions ​

A subscription is a list of servers from a provider: by URL or from a file. Each server becomes an outbound named <subscription>/<server>, and all servers of the subscription are collected into a group named after the subscription.

yaml
outbounds:
  direct:
    direct:

subscriptions:
  work:
    remote:
      url: https://panel.example.com/sub/abc
      update: 6h
      headers:
        User-Agent: my-router/1.0
    exclude: '(?i)russia|🇷🇺'
    group:
      rank:
        delay:
          probe:
            interval: 5m

groups:
  main:
    members: [work, direct]

route:
  final:
    group: main

Here work is a group of all the subscription's servers with a choice by delay; main is a manual choice between it and the direct outbound.

The content formats and what is taken from them are in Subscription formats.

Fields ​

FieldMeaning
remoteAn http:// or https:// URL as a string, or a download block (below). Exactly one of remote and file
fileA file on disk; reread when it changes
groupA group of the subscription's servers, see below
import_groupsWhich of the provider's groups to take, see below
renameRenaming servers
include, excludeFilters by name
protocolsKeep only servers of these protocols: [vless, hysteria2]
patchChanges applied to each server

Download fields exist only in remote and are written inside its block; next to remote or file they are the error `update` belongs inside the `remote` block:

Field of the remote blockMeaning
urlAn http:// or https:// URL; required
updateHow often to download again; 1h by default
viaThe outbound or group to download through; without it, directly
headersRequest headers: a mapping "name → value"
hwidWhat to send in the X-HWID header, see below

Request: User-Agent and X-HWID ​

Without User-Agent in headers, ours/<version> is sent. Many panels choose the answer format by User-Agent; if a panel serves a format that cannot be read here, set the User-Agent of a client for which it serves links, Xray JSON or Clash YAML.

hwid is the device identifier by which providers count devices:

ValueWhat goes into X-HWID
auto (default)A constant value for this machine and this subscription: a hash of /etc/machine-id (or the MAC of the first network card) and the URL
randomA new random value on every download
noneThe header is not sent
another stringThe value itself

If X-HWID is in headers, that is what is sent, and a hwid field next to it is an error.

Server names: rename, include, exclude ​

yaml
subscriptions:
  work:
    file: servers.txt
    rename:
      - pattern: '^DE-(.*)$'
        to: 'Germany-$1'
      - pattern: '\s*\[.*\]'
        to: ''
    include: '(?i)germany|netherlands'
    exclude: '(?i)test'
    protocols: [trojan, vless]
  • rename is a list of {pattern, to} replacements "regular expression → string", applied in order to the whole name; $1, ${1}, ${name} are available in to.
  • include and exclude are regular expressions on the name after rename, matching anywhere.
  • Regular expressions have no backreferences and no lookaround. An error in an expression is a load error.
  • An empty name is replaced with the server's host:port, a repeat with name-1, name-2; the characters * ? [ ] { } with _.

Changing servers: patch ​

Outbound blocks that are merged with each server field by field; the value from patch wins, and null removes a field or block:

yaml
subscriptions:
  work:
    remote: https://panel.example.com/sub/abc
    patch:
      dial:
        connect_timeout: 5s
      tls:
        utls:
          fingerprint: firefox
      mux: null
  • dial is added to every server; mux to servers of the vless, trojan, shadowsocks protocols.
  • tls, transport and the protocol block change only for servers that already have them: a patch does not enable TLS on a server without it.
  • A transport and mux of another kind are replaced whole.
  • The order of layers: outbounds.defaults < the server < patch.

Groups ​

The subscription's group: group ​

By default a group named after the subscription is created, with all its servers as members (match: "work/*") and rank: manual. group takes the group fields except members. group: false means no group is created.

The provider's groups: import_groups ​

Clash proxy-groups and Xray balancers become groups <subscription>/<name>:

ValueWhich groups are taken
auto (default)All except those that contain all the subscription's servers
allAll
noneNone

As a block: import_groups: {take: all, as: {rank: {delay: {}}}} — take as above, as group fields that replace the way of choosing set by the provider.

References to servers and groups ​

  • A subscription server cannot be a direct target: to: {outbound: work/de-1}, final, dial.detour and via naming it are errors. Put it in a group (members: [work/de-1]) and target the group. In the members of groups and in the outbound condition of DNS rules the servers are available, by name or by the pattern work/*.
  • A name or pattern that currently selects nothing gives a warning, not an error.
  • A provider's group can be referenced from a rule: to: {group: work/Auto}. If the provider removed it, the name stays a group of one member, the target of route.final (if final is an outbound or a group), otherwise an empty group that refuses connections. A warning is written about it.

Updates ​

  • At startup the servers are taken from the file or from the cache (if enabled), without the network; then remote is downloaded.
  • If the set of servers changed, the configuration is rebuilt as on reload, with the reload policy. A failed download keeps the previous servers; the retry is after min(update, 5m).
  • Repeated downloads are conditional (ETag, Last-Modified). The cache keeps the content, the URL and subscription-userinfo; when the URL changes the cache is not used.
  • A server that fails the check as an outbound (after patch) is skipped with the reason, together with the servers that connect through it.

To see what the subscriptions contain: ours check --fetch (Command line). In the dashboard the subscriptions are visible in the Overview, with the update button there too.

GPL-3.0-or-later