Skip to content

Subscribe files

A subscribe file is what a proxy provider hands a client: the servers it offers (nodes), a DNS setup, and route groups that say which traffic should go through which node. It is a TOML file of its own, separate from the configuration file. The configuration’s [subscribe] section names the file and picks a node for each route group, and etemenanki-app merges the two at every load.

etemenanki-app never downloads a subscribe file. You, or the program that manages your client, put it on disk, and saving it reloads the proxy like saving the configuration does.

Use a subscribe file on a client that takes its servers from a provider. A server that you configure yourself needs none: write its outbounds and rules in the configuration file.

File Written by Holds
The subscribe file The provider [[proxy_server]] nodes, an optional [dns], and [[route_group]] groups
The configuration file You The inbounds, the geodata paths in [route], [subscribe] with your picks, and optionally outbounds, balancers and [api] of your own

The configuration keeps what is yours: two local inbounds, the geodata files, the subscribe file’s path and your picks. The subscribe file brings five nodes, a DNS setup and four route groups. Every value in it is a placeholder.

config.toml
# A local client that takes its nodes, route groups and DNS setup from a
# subscribe file. This file keeps what is yours: the inbounds, the geodata
# paths, and which node each route group uses.
#
# Put the provider's file at the path below. Saving either file reloads.
[[inbound]]
tag = "socks-in"
protocol = "socks"
listen = "127.0.0.1"
port = 1080
[[inbound]]
tag = "http-in"
protocol = "http"
listen = "127.0.0.1"
port = 8080
# Routing comes from the subscribe file's route groups. [route] still names
# the geodata files those groups use.
[route]
geoip = "/etc/etemenanki/geoip.dat"
geosite = "/etc/etemenanki/geosite.dat"
[subscribe]
path = "/etc/etemenanki/subscribe.toml"
# Your picks: a route group's name, or `default` for traffic no group
# matches, and the node (or outbound, balancer, "direct" or "blackhole")
# that carries it. A group without a pick uses what it inherits.
[subscribe.routes]
default = "vless-ws"
Streaming = "trojan-tls"

With these two files, traffic goes here:

Traffic Group Goes to Why
Ad domains Ads blackhole No pick; the group inherits blackhole
Netflix Streaming trojan-tls Picked in [subscribe.routes]
Private addresses and .lan names Local direct No pick; the group inherits direct
example.org and all UDP Proxy vless-ws No pick; the group inherits default, which is picked as vless-ws
Everything else none vless-ws The default pick

Groups are tried from top to bottom, so UDP traffic to a private address goes to Local, not to Proxy.

  1. Save the provider’s file at the path [subscribe] path names.

  2. Check both files together: etemenanki-app --test -c /etc/etemenanki/config.toml reads the subscribe file as a start would.

  3. Start the proxy, or save the configuration if it already runs.

KeyTypeRequiredDefaultDescription
pathpathyes—The subscribe file. A relative path resolves against the working directory of the process, like every other path in the config. Without it the config is refused with [subscribe] needs a path naming the subscribe file. The file is read at every load, and a change to it reloads.
routestableno—Your picks, written as [subscribe.routes]: each key is a route group's name, or default for traffic no group matches, and each value is the tag that carries that traffic. A value may name a node, one of the config's own outbounds or balancers, direct or blackhole. A key that is not a group ([subscribe.routes] names "…", which is not a route group in <file>) or a value that names nothing ([subscribe.routes] "…" = "…": no node, outbound or balancer has that name) fails the config. A group without a pick uses what it inherits. default overrides [route] default.

A configuration with [subscribe] needs no [[outbound]] of its own: the nodes are outbounds.

flowchart LR
  SUB["subscribe file"] --> NODES["nodes"]
  SUB --> GROUPS["route groups"]
  SUB --> SDNS["[dns]"]
  CFG["config file"] --> IN["[[inbound]]"]
  CFG --> OWN["own outbounds and balancers"]
  CFG --> PICKS["[subscribe.routes]"]
  NODES --> OUT["outbounds"]
  OWN --> OUT
  GROUPS --> RULES["route rules"]
  PICKS --> RULES
  SDNS --> DNS["resolvers"]
  • Nodes become outbounds, each tagged with its name, after the configuration’s own outbounds. A route rule, a pick or a balancer can name a node like any outbound.
  • Route groups become the route rules, in file order, and the first rule that matches wins. The configuration’s own [[route.rule]] entries are ignored, with a warning: [subscribe] is set, so the config's <n> [[route.rule]] entries are ignored; routing comes from the route groups in <file>. [route] geoip and geosite still name the geodata files the groups use.
  • The default route is the default pick in [subscribe.routes], else [route] default, else the first outbound: the configuration’s first, or the first node when it has none.
  • The file’s [dns] replaces the configuration’s [dns]. When the configuration’s [dns] sets anything, a warning says it is ignored: <file> has a [dns] section, so the config's [dns] is ignored. Without [dns] in the file, the configuration’s [dns] applies as usual.
  • direct and blackhole exist when a route names them. A group that inherits direct, or a pick of blackhole, needs no outbound of that name: etemenanki-app adds a freedom or blackhole outbound. With a subscribe file, a tag that a route uses as direct or blackhole must really be one: a configuration outbound of another protocol, or a balancer, with that tag is refused, so traffic meant to go direct cannot leave through a proxy that happens to be called direct.
  • Everything else stays the configuration’s: every inbound, and the configuration’s own outbounds and balancers.

Each node is one [[proxy_server]] table. name, server, port and protocol are common to all nodes; protocol decides which of the other keys the node takes. The key names follow the app’s [outbound.settings], so a node reads like the outbound it becomes, and it is checked the same way: an error in a node names it as an outbound, for example outbound wg: invalid wireguard private_key.

KeyTypeRequiredDefaultDescription
namestringyes—The node's name, which is the tag of the outbound it becomes and what a pick names. It must differ from every other node and from the config's own outbound and balancer tags (subscribe: node "…" is defined twice, or shares its name with a config outbound).
serverstringyes—Host name or IP address of the server, without a port. Write an IPv6 address bare (2001:db8::10). A name is looked up with the pre_proxy servers of the file's [dns] (or the config's [dns] when the file has none).
portu16yes—The server's port: UDP for hysteria2 and wireguard, TCP for the others.
protocolstring (enum)yes—One of vless, vmess, trojan, shadowsocks, socks, http, hysteria2, wireguard, anytls or sss, spelled exactly. The app's aliases such as hy2 are not accepted here. It decides which of the keys below the node takes; a key of another protocol fails the parse, and so does a protocol the reader does not know (unknown variant).
streamtableno—vless, vmess, trojan, shadowsocks, socks, http and sss: the transport, as an inline table such as { network = "ws", path = "/ws", tls = {} }. See the stream table below. Absent means plain TCP. anytls has no stream: it always runs over TLS, with its TLS keys in the node.
idstringdepends—vless, vmess and sss, required: the user's UUID.
flowstring (enum)no—vless: the XTLS flow, xtls-rprx-vision or left out. It needs a reality stream (vless vision (xtls-rprx-vision) rides only over reality); any other value fails with unknown vless flow.
securitystring (enum)no"auto"vmess: the body cipher, auto (AES-128-GCM), aes-128-gcm or chacha20-poly1305, spelled exactly.
methodstring (enum)depends—shadowsocks, required: aes-128-gcm, aes-256-gcm, chacha20-poly1305 (or chacha20-ietf-poly1305), xchacha20-poly1305 (or xchacha20-ietf-poly1305), 2022-blake3-aes-128-gcm, 2022-blake3-aes-256-gcm or 2022-blake3-chacha20-poly1305.
passwordstringdepends—trojan, shadowsocks, hysteria2 and anytls, required. For a Shadowsocks 2022 method, the base64 key, or iPSK:uPSK for a multi-user server. For a Hysteria 2 server with per-user accounts, user:pass.
userstringno—socks and http: the account's user name.
passstringno—socks and http: the account's password.
server_namestringno—hysteria2 and anytls: the TLS server name, sent as SNI and checked against the certificate. Defaults to the node's server.
allow_insecureboolnofalsehysteria2 and anytls: accept any certificate. Use it only for testing.
obfstableno—hysteria2: Salamander obfuscation, written { type = "salamander", password = "…" }. The password must be at least 4 bytes and match the servers.
portsstringno—hysteria2: port hopping, every port the server answers on, such as "443,20000-30000". The node still needs port. The hop interval defaults to 30 seconds.
hop_intervalu64no—hysteria2: seconds on one port before hopping, at least 5. Needs ports.
upstringno—hysteria2: the most the client sends at, as a number and a unit such as "50 mbps". It becomes the outbound's bandwidth.up.
downstringno—hysteria2: the most the client receives at, which the server is told. It becomes the outbound's bandwidth.down.
private_keystringdepends—wireguard, required: your private key, as in a wg-quick file.
peer_public_keystringdepends—wireguard, required: the peer's public key.
preshared_keystringno—wireguard: the pre-shared key, when the peer has one for you.
addressarray of IPsdepends—wireguard, required: your tunnel addresses as bare IPs, such as ["10.0.0.2", "2001:db8:a::2"]. The peer is the node's server and port.
mtuintegerno1420wireguard: the tunnel MTU.
keepaliveu16no—wireguard: persistent keepalive, in seconds.
reservedarray of integersno—wireguard: exactly three bytes for the reserved header field, only when the service asks for them.
transformtableno—sss: the server's transform chains from the client's view, written { up = […], down = […] }: each direction is an array of expressions in the same notation as the outbound key, run in the order written. A single expression is written as an array of one. Without it, both chains are the identity. The chains are checked when the node becomes an outbound.
udp_max_datagramu16no65535sss: the largest datagram one UDP record carries, as the server sets it.

Three kinds of node have a shape of their own:

  • AnyTLS runs over TLS on TCP and nothing else, so its node has no stream. Its TLS keys, server_name and allow_insecure, sit in the node itself, as for Hysteria 2, and the node becomes an anytls outbound with network = "tls". See AnyTLS.
  • VLESS over REALITY is a vless node whose stream has network = "reality"; see the stream table. Such a node may also set flow = "xtls-rprx-vision". The flow rides only over REALITY: on any other stream the node fails with outbound <name>@v0: vless vision (xtls-rprx-vision) rides only over reality, and a REALITY stream on another protocol with outbound <name>@v0: reality is for vless only.
  • sss takes the user’s id, its transform chains and udp_max_datagram, over any stream but REALITY. Its keys are described on sss.
[[proxy_server]]
name = "tw-anytls"
server = "proxy.example.com"
port = 443
protocol = "anytls"
password = "replace-with-a-long-random-password"
server_name = "proxy.example.com" # optional: defaults to server
[[proxy_server]]
name = "fra-reality"
server = "203.0.113.10"
port = 443
protocol = "vless"
id = "11111111-2222-3333-4444-555555555555"
flow = "xtls-rprx-vision"
stream = { network = "reality", public_key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", server_name = "www.example.com", short_id = "0123456789abcdef" }

Every value here is a placeholder. The REALITY public_key is the server’s X25519 public key in unpadded base64url, 43 characters; server_name is the site the server passes itself off as, not the node’s own server.

A node cannot carry keys that depend on the client’s own machine or taste:

Not in a node What the node gets instead
ca_file The system roots, or no verification with allow_insecure
address_family Derived from [dns] connect_ipv6 when the file has [dns], else auto
Hysteria 2 max_concurrent_streams The default, 102,400
Hysteria 2 congestion, quic, min_hop_interval, max_hop_interval and bandwidth.disable_loss_compensation The defaults: Cubic, upstream’s QUIC values, a fixed hop interval and loss compensation on. The node’s up, down, ports and hop_interval become the outbound’s bandwidth.up, bandwidth.down, ports and hop_interval
WireGuard endpoint The node’s server and port, joined as server:port; an IPv6 server may be bare or in brackets
AnyTLS client, idle_session_check_interval, idle_session_timeout and min_idle_session The defaults: an empty client, a check of the idle sessions every 30 seconds, a 30-second idle timeout and no idle session kept
sss flush_delay "0ms"
KeyTypeRequiredDefaultDescription
networkstring (enum)yes—tcp, ws, grpc or reality. There is no tls network here: TLS is on whenever the tls table is present. reality is VLESS over REALITY on plain TCP; it takes public_key, server_name and short_id, and no tls table.
pathstringno"/"ws: the WebSocket path.
hoststringno—ws: the Host header. Defaults to tls.server_name, then to the node's server.
service_namestringdepends—grpc, required: the gRPC service name.
authoritystringno—grpc: the HTTP/2 :authority. Defaults to tls.server_name, then to the node's server.
tlstableno—tcp, ws and grpc: turns TLS on, including as an empty tls = {}. Its keys are server_name and allow_insecure.
public_keystringdepends—reality, required: the server's X25519 public key, unpadded base64url of 32 bytes (43 characters).
server_namestringdepends—reality, required: the SNI the client sends, the name of the site the server passes itself off as, not the node's own server.
short_idstringno—reality: the shortId the client presents, up to 16 hex digits. Leave it out when the server admits the empty shortId.
KeyTypeRequiredDefaultDescription
server_namestringno—The name sent as SNI and checked against the certificate. Defaults to the node's server.
allow_insecureboolnofalseAccept any certificate. A node has no ca_file: without this key, the certificate is checked against the system roots.

The stream becomes the outbound’s [outbound.stream]:

Node stream Outbound stream
Absent, or { network = "tcp" } Plain TCP
{ network = "tcp", tls = {} } network = "tls"
{ network = "ws", tls = {} } network = "ws", security = "tls"
{ network = "grpc", service_name = "…", tls = {} } network = "grpc", security = "tls"
{ network = "reality", public_key = "…", server_name = "…", short_id = "…" } security = "reality", with public_key, server_names = [server_name] and short_ids = [short_id] in [outbound.stream.reality]

A reality stream takes no tls table: REALITY brings its own handshake. Its short_id is optional and is left out when the server admits the empty shortId. See Transports for what each stream does on the wire, and REALITY for REALITY.

The subscribe format has a revision, the version of the etemenanki-subscribe crate that reads it, and it grows as protocols are added:

Node Needs revision
AnyTLS, a reality stream, a VLESS flow 0.3 or later
sss 1.1 or later

etemenanki-app 3.0 reads revision 1.1. A file has no revision marker, and a reader refuses a whole file over a protocol or network it does not know: subscribe: TOML parse error at line <n>, column <m>, with unknown variant and the values it knows. A client that downloads subscribe files puts the revision it reads in its User-Agent as etemenanki-subscribe/<version>, so that a provider can leave out the nodes that client could not read. etemenanki-app itself never downloads the file, so it sends no User-Agent.

A node that the format can describe but etemenanki-app cannot turn into an outbound is a configuration error that names the node. That can happen only when etemenanki-app is built with a later etemenanki-subscribe than the one it was released with: subscribe: node "<name>": its protocol is not supported by this version, or its stream, its vmess security, its shadowsocks method in place of its protocol.

A provider that suggests no DNS setup leaves [dns] out. A [dns] table that is present must set all five keys.

KeyTypeRequiredDefaultDescription
pre_proxyarray of stringsyes—Servers asked directly, before any proxy is up. They look up the nodes' host names and the host names of the through_proxy servers. Write each as an address: a name here is refused when the resolvers are built. May be empty.
through_proxyarray of stringsyes—Servers asked through the route table: they look up everything else, including the destinations of direct and applications' own DNS queries. system is refused here. A name is looked up with pre_proxy. May be empty, and then pre_proxy answers everything.
use_hostsboolyes—Answer from the system hosts file before asking any server.
connect_ipv6string (enum)yes—How a node whose name has both A and AAAA records is reached: required (IPv6 only), preferred (IPv6 first), tolerated (IPv4 first) or forbidden (IPv4 only). It becomes each node's address_family (for a WireGuard node, its endpoint_address_family).
resolve_ipv6boolyes—Whether applications behind the client get AAAA answers to their DNS queries.

Each server in pre_proxy and through_proxy is one string:

Form Server Default port
"system" The host resolver. Allowed in pre_proxy only. —
"udp://192.0.2.53:53" Plain DNS 53
"tls://203.0.113.53:853#dns.example.com" DNS over TLS. The part after # is the name the certificate is checked against; without it, the host is. 853
"https://dns.example.com/dns-query" DNS over HTTPS. A URL without a path gets /dns-query. 443

An IPv6 host is written in brackets here, as in udp://[2001:db8::53]:53.

A subscribe file’s [dns] splits name resolution in two:

Resolver Servers Looks up
Direct pre_proxy, asked from this host The nodes’ server names (WireGuard endpoints included), balancer probes, and the names of through_proxy servers
Proxied through_proxy, reached through the route table The destinations that direct and WireGuard tunnels connect to, and the DNS queries of applications. With through_proxy empty, the direct resolver does this too.

A query to a through_proxy server travels as a TCP connection to that server’s address and port, and the route groups decide where it goes, as for any other connection: a group with a matching cidr, geoip, port or network entry carries it. Domain matchers never match it, because its destination is an address.

With use_hosts = true, both resolvers answer from the system hosts file before they ask a server.

With a subscribe file’s [dns], etemenanki-app answers the DNS queries of the applications behind it. Every connection to port 53, over TCP or UDP and on any inbound, is answered from the proxied resolver instead of being routed, whatever DNS server the application asked. AAAA answers are returned only with resolve_ipv6 = true.

Without [dns] in the subscribe file there is no such service: a query to port 53 is routed like any other connection.

KeyTypeRequiredDefaultDescription
namestringyes—What the client shows and what [subscribe.routes] picks by. Unique in the file (subscribe: route group "…" is defined twice), and never default, which [subscribe.routes] keeps for the default route.
inheritstring or tableno"default"Where the group's traffic goes while it has no pick: "default" (wherever unmatched traffic goes), "direct", "blackhole", or { group = "<name>" } to follow another group.
matchesarray of tablesno[]What the group matches, as one-key tables such as { geosite = ["netflix"] }. The group matches a flow when any entry matches, and an entry matches when any of its values does. An empty list matches nothing, but the group can still be inherited from.

Each entry of matches is a table with one of these keys. The value syntax is that of the app’s own route rules:

KeyTypeRequiredDefaultDescription
domain_fullarray of stringsno—The exact domain.
domain_suffixarray of stringsno—The domain or any of its subdomains.
domain_keywordarray of stringsno—A substring of the domain.
domain_regexarray of stringsno—A regular expression over the lower-cased domain, not anchored.
cidrarray of stringsno—A destination IP range such as "192.0.2.0/24". Never matches a destination given as a domain.
portarray of stringsno—A destination port "443" or range "8000-9000".
networkarray of stringsno—"tcp", "udp" or both.
geositearray of stringsno—A geosite list, "code" or "code@attr", from the config's [route] geosite file.
geoiparray of stringsno—A GeoIP list, "code" or "!code", from the config's [route] geoip file.

A route group has no inbound_tag or source_cidr matcher: those depend on the client’s own setup, which a provider cannot know.

inherit decides where a group’s traffic goes while you have not picked a node for it:

inherit Traffic goes to
Absent, or "default" The default route
"direct" direct, without a proxy
"blackhole" blackhole: connections are dropped
{ group = "Proxy" } Wherever the group Proxy goes: its pick, or else what it inherits in turn

Your picks live in [subscribe.routes] in the configuration file. The subscribe file is never edited, so a provider can replace it without losing your choices.

  • To switch by hand, edit [subscribe.routes] and save. The reload applies it.
  • To switch from a program, use the REST API: PUT /v1/routes/<group> rewrites the same key and reloads, and keeps the file’s comments and layout.

A value may name a node, one of the configuration’s own outbounds or balancers, direct or blackhole. default picks the route for traffic that no group matches.

When a switch moves a group between outbounds that exist already, only the route table is rebuilt: connections that are open keep the outbound they were opened on, and new connections of that group take the new pick. A REST API switch with "close": true also closes the open connections it moved, so they reconnect through the new pick.

etemenanki-app watches the directory of the subscribe file as well as the configuration’s. When either file changes, it reloads:

  • Replace the file in one step: write the new file next to the old one and rename it over it, so that a reload never reads a half-written file.
  • A reload applies what changed. A node whose settings are unchanged, in a file whose DNS setup is unchanged too, is kept as it runs. A node whose settings changed is built anew, and new connections use the new settings.
  • A pick must keep naming something. When a new file renames or removes a node that [subscribe.routes] picks, the whole load is refused with [subscribe.routes] "<group>" = "<node>": no node, outbound or balancer has that name. Update the pick, then the file, or both before the next reload.
  • A file that is refused leaves the running configuration in place, and the log says why. See Hot reload.

The merge’s own errors start with subscribe: . They appear after configuration invalid: under --test, after failed to start: at startup, and in the reload: …; keeping the running config line on a reload.

Error Cause
[subscribe] needs a path naming the subscribe file [subscribe] has no path.
subscribe: TOML parse error at line <n>, column <m> The subscribe file does not parse: a syntax error, an unknown or missing key, a key of another protocol in a node, or a [dns] without all five keys.
subscribe: node "<name>" is defined twice, or shares its name with a config outbound Two nodes share a name, or a node has the tag of one of your outbounds or balancers.
subscribe: a route group may not be named "default": [subscribe.routes] uses that key for the default node A group is called default.
subscribe: route group "<name>" is defined twice Two groups share a name.
subscribe: [subscribe.routes] names "<key>", which is not a route group in <file> A pick names a group the file does not have, often after the provider renamed it.
subscribe: [subscribe.routes] "<key>" = "<tag>": no node, outbound or balancer has that name A pick names nothing: a node that was renamed or removed, or a typo.
subscribe: no node or outbound to send unmatched traffic to There is no default pick, no [route] default, no outbound and no node.
subscribe: "direct" is routed to, but the outbound tagged "direct" is "socks", not "freedom" A route uses direct, and one of your outbounds of another protocol has that tag. The same check applies to blackhole, and to a balancer with either tag.
outbound <name>: … A node’s value is wrong, for example a malformed UUID or key. The name is the node’s.
subscribe: node "<name>": its protocol is not supported by this version The node is of a kind this etemenanki-app cannot convert; see Format revisions.
dns: server "<server>": … A pre_proxy or through_proxy string does not parse.
building dns failed: dns: the system resolver cannot be reached through a proxy "system" is listed in through_proxy.
building dns failed: dns: server "<name>" is a name, and nothing resolves it; write its address A pre_proxy server is written by name.