The configuration file
etemenanki-app reads one TOML file. It describes where clients connect (inbounds), where their traffic leaves (outbounds), how each flow picks an outbound (routing), and a few process-wide settings such as logging and DNS. On a client, the file can also name a subscribe file that supplies the servers and the routing, and it can turn on the REST API. This page covers the file as a whole: its layout, how strictly it is checked, the errors you will see, and the [log] table. Each section of the file has its own page, linked at the end.
Read this page before you write your first file by hand, or when --test rejects a file and the error message is not enough.
At a glance
Section titled “At a glance”The smallest useful file is a local SOCKS proxy that sends everything straight out:
[[inbound]]tag = "socks-in"protocol = "socks"listen = "127.0.0.1"port = 1080
[[outbound]]tag = "direct"protocol = "freedom"Pass the file with -c (long form --config). Without it, etemenanki-app reads config.toml in the current working directory. Check a file without starting anything with --test:
etemenanki-app --test -c /etc/etemenanki/config.toml--test runs every check a real start runs and reads every file the configuration needs, the subscribe file included, but binds no listener, opens no TUN device and does not start the API. On success it prints Configuration OK. and exits with status 0. On failure it logs configuration invalid: … and exits with status 1.
-
Write or edit the file.
-
Run
etemenanki-app --test -c <file>. -
If it fails, fix the error it names and run it again. Only the first error is reported, so a file with three mistakes takes three rounds.
-
Start the proxy with
etemenanki-app -c <file>, or save the file in place if the proxy is already running: it reloads on its own (see Hot reload).
Top-level structure
Section titled “Top-level structure”A file is made of eight top-level entries. All of them are optional to the TOML parser. What the file needs in the end is somewhere to send traffic: an [[outbound]], a node from a subscribe file, or a route that names direct or blackhole.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
log | table | no | {} | Logging, written as [log]. Holds only level. See the [log] section of the configuration file page. |
dns | table | no | {} | Name resolution for proxy servers, WireGuard endpoints, balancer probes and freedom destinations, written as [dns]. Without it, etemenanki-app uses the host resolver behind an always-on cache. When [subscribe] names a subscribe file that has its own [dns], that one is used instead. |
inbound | array of tables | no | [] | The listeners, one [[inbound]] block each. Written in the singular: [[inbounds]] is an unknown field. Zero inbounds is valid, although such a process accepts nothing. Tags must be unique among inbounds. |
outbound | array of tables | depends | — | Where flows leave, one [[outbound]] block each. Written in the singular. Tags must be unique among outbounds. The first [[outbound]] in the file is the default route unless [route] sets default. A config needs at least one outbound (config defines no outbounds), but direct and blackhole need no block: when a route names one of them and no outbound or balancer carries that tag, etemenanki-app adds it as a freedom or blackhole outbound. With [subscribe], the subscribe file's nodes are added after the config's own outbounds. |
balancer | array of tables | no | [] | Groups of interchangeable outbounds, one [[balancer]] block each. Written in the singular. A balancer tag can be used wherever an outbound tag is accepted, so it must not repeat an outbound tag or another balancer tag. |
route | table | no | {} | Routing, written as [route], with its rules as [[route.rule]] blocks (singular; [[route.rules]] is an unknown field). The first matching rule wins. Without [route], every flow goes to the first [[outbound]]. With [subscribe], the rules come from the subscribe file's route groups instead. |
subscribe | table | no | — | A subscribe file that supplies the client side, written as [subscribe]: its nodes become outbounds, its route groups become the route rules, and its [dns], if it has one, replaces this files. [subscribe.routes] picks the node for each route group. Every [[inbound]] stays this files. |
api | table | no | — | The REST API that switches a route group's node by editing this file, written as [api]. Without it, the API does not listen. |
This is how the sections relate to each other. Dashed lines are lookups rather than traffic.
flowchart LR IN["[[inbound]]"] --> R["[route] and [[route.rule]]"] R --> OUT["[[outbound]]"] R --> BAL["[[balancer]]"] BAL --> OUT DNS["[dns]"] -.-> OUT DNS -.-> BAL SUB["[subscribe]"] -.->|"nodes"| OUT SUB -.->|"route groups"| R SUB -.->|"its [dns]"| DNS API["[api]"] -.->|"edits picks"| SUB API -.->|"edits default"| R
Array tables and sub-tables
Section titled “Array tables and sub-tables”inbound, outbound, balancer and route.rule are arrays of tables: you write [[inbound]] with double brackets once per entry. The names are singular, even though Xray’s JSON spells the same lists inbounds and outbounds.
| You write | Result |
|---|---|
[[inbound]] |
One more inbound. |
[[inbounds]] |
A parse error at that line: the top-level key is inbound. |
[inbound] (single brackets) |
A parse error at that line: inbound is a list, written [[inbound]]. The same happens for [outbound], [balancer] and [route.rule]. |
[[route.rule]] |
One more routing rule. |
[[route.rules]] |
A parse error at that line: the key is rule. |
Nested tables such as [inbound.settings], [inbound.stream] or [outbound.stream.tls] attach to the closest [[inbound]] or [[outbound]] above them. That is plain TOML, and it is the easiest mistake to make when you move blocks around.
When order matters
Section titled “When order matters”The position of a section in the file does not matter, with two exceptions:
[[outbound]]order. The first[[outbound]]is the default route when[route]has nodefault.[[route.rule]]order. Rules are tried from top to bottom and the first match wins. See Routing.
With [subscribe], the subscribe file’s nodes come after your own outbounds, and its route groups, in their file order, take the place of your rules. Order also decides which error you see first when a file has several; see How a file is checked.
Strict by design
Section titled “Strict by design”etemenanki-app fails closed: a mistake stops the proxy with an error instead of quietly changing what it does. A misspelled listen that fell back to a default could put a proxy meant for localhost on the network; a misspelled security that fell back to plaintext would send credentials in the clear. Both are refused.
Unknown keys are errors
Section titled “Unknown keys are errors”Every table in the file rejects keys it does not know. That includes the nested stream, tls, ws, grpc and reality tables, [subscribe] and [api], and, for every protocol that has settings, its settings table. Keys are case-sensitive, so Tag is as unknown as lisen. A misspelled key outside a settings table stops the parse with an error that points at it:
configuration invalid: TOML parse error at line 8, column 1The only alias in the whole schema is clients for users in a Shadowsocks inbound’s settings, accepted for Xray compatibility.
Unknown values are errors
Section titled “Unknown values are errors”Values such as protocol, network and strategy are plain strings to the TOML parser. etemenanki-app matches each one against the values it supports, and anything else is an error. None of them falls back to a default.
Most of these comparisons are exact and case-sensitive. A few are forgiving:
| Value | Accepted spelling | Example of a rejected value |
|---|---|---|
protocol (inbound and outbound) |
Exact, lower case. Aliases: hysteria and hy2 for hysteria2; on an outbound also direct for freedom and block for blackhole. |
"Freedom" → outbound direct: unknown protocol "Freedom" |
[.stream] network |
Exact: tcp, tls, ws, grpc. |
"WS" → inbound a: unknown stream network "WS" |
[.stream] security |
Exact after trimming spaces: tls, reality, none or empty. tls is refused with network = "tcp"; TLS over TCP is network = "tls". reality needs network = "tcp" and a VLESS inbound or outbound. |
"TLS" → inbound a: unknown stream security "TLS" (expected "tls" or "none") |
VLESS flow |
Exact: xtls-rprx-vision, or empty. |
"xtls-rprx-direct" → outbound p: unknown vless flow "xtls-rprx-direct" |
sss reject |
Exact: "drain", or a { fallback = "ip:port" } table. |
"close" → inbound sss-in: reject is neither "drain" nor { fallback = "ip:port" } |
[[balancer]] strategy |
Exact: failover, round_robin. |
"Failover" → balancer auto: unknown balancer strategy "Failover" (expected "failover" or "round_robin") |
[dns] backend |
Exact: system, udp, tls, https. |
"UDP" → dns: unknown backend "UDP" (expected "system", "udp", "tls" or "https") |
[[route.rule]] network |
Exact: tcp, udp. |
"TCP" → invalid rule network "TCP" (expected "tcp" or "udp") |
SOCKS inbound auth, Hysteria 2 obfs |
Exact. | "Password" → inbound socks-in: unknown socks auth "Password" |
Outbound address_family, WireGuard endpoint_address_family |
Case-insensitive, spaces trimmed, - read as _. |
"ipv5" → outbound direct: invalid address_family "ipv5" |
VMess outbound security |
Case-insensitive. | "none" → outbound v: unknown vmess security "none" |
Shadowsocks method |
Case-insensitive for the AEAD methods; exact for the 2022- methods. |
"2022-BLAKE3-AES-128-GCM" → inbound a: unknown shadowsocks-2022 method "2022-BLAKE3-AES-128-GCM" |
[log] level |
Case-insensitive, but never rejected. See Logging. | "warning" is accepted and silences logging. |
Tags are compared exactly too: default = "home" does not find an outbound tagged "Home".
How a file is checked
Section titled “How a file is checked”Whenever etemenanki-app loads the file, for --test, at startup, for a reload and before the REST API writes a change, it runs the same stages. Only a real start or reload goes on to bind listeners.
flowchart LR A["read the file, and the subscribe file it names"] --> B["1. parse"] B --> C["2. lowering"] C --> D["3. validation"] D --> E["4. build"] E --> T["--test: Configuration OK."] E --> S["start or reload: bind listeners, open TUN devices"] B & C & D & E -->|"first error"| X["refused"]
| Stage | Checks | Errors look like |
|---|---|---|
| 1. Parse | TOML syntax, UTF-8, unknown keys, value types (a string where a number belongs, a port above 65535), required keys such as tag and protocol. The subscribe file is parsed here too. |
TOML parse error at line <n>, column <m>, or subscribe: TOML parse error at line <n>, column <m> |
| 2. Lowering | Every settings table; every enumerated value; strings with a syntax of their own (UUIDs, keys, CIDRs, ports, regular expressions, DNS servers); the files the configuration names; users without a name or with a name taken twice; key combinations that mean nothing; the subscribe file’s merge; [api] |
inbound <tag>: …, outbound <tag>: …, balancer <tag>: …, dns: …, subscribe: …, [api] …, invalid cidr … |
| 3. Validation | Tags (unique and not empty) and the tags that rules and balancers name; balancer members; two inbounds on one address and port; two users presenting one credential; limits and key lengths | duplicate inbound tag <tag>, route references unknown outbound <tag>, inbound <tag>: …, outbound <tag>@v0: … |
| 4. Build | Everything is constructed as a start would construct it, without binding: the resolvers, every outbound and balancer, the route table with the geodata it uses, and every inbound handler with its certificate | building <what> failed: …, for example building route failed: … or building inbound socks-in failed: … |
Within stages 2 and 3 the order is fixed, and the first error stops the check. Lowering takes [dns] first, then each [[outbound]] in file order, each [[balancer]], [route], and last each [[inbound]]. Validation checks the tags first, then each outbound, the balancers, the route’s references, and last each inbound. So a broken rule is reported before a broken inbound even if the inbound comes first in the file, and a malformed UUID before a duplicate tag.
Errors in a settings table
Section titled “Errors in a settings table”A settings table is checked while lowering, so its errors carry no line number. They name the object instead, in the form inbound <tag>: invalid settings: … or outbound <tag>: invalid settings: …:
[[inbound]]tag = "socks-in"protocol = "socks"port = 1080
[inbound.settings]auth = "password"acounts = [{ user = "alice", pass = "replace-with-a-long-random-password" }]inbound socks-in: invalid settings: unknown field `acounts`, expected one of `auth`, `accounts`, `udp`, `udp_bind`[[outbound]]tag = "trojan-out"protocol = "trojan"server = "proxy.example.com"port = 443outbound trojan-out: invalid settings: missing field `password`[[inbound]]tag = "socks-in"protocol = "socks"port = 1080
[inbound.settings]udp = "yes"inbound socks-in: invalid settings: invalid type: string "yes", expected a booleanin `udp`Search the file for the tag in the message to find the table.
Where the errors appear
Section titled “Where the errors appear”The error text is the same in every situation; only the line around it differs:
| Situation | Log line | What happens |
|---|---|---|
etemenanki-app --test |
configuration invalid: <error> |
Exits with status 1. |
| Startup | failed to start: <error> |
Exits with status 1. |
| Reload | reload: <error>; keeping the running config |
The running configuration stays in place. |
| Reload of a change that would end live connections, such as a TUN change | reload refused, keeping the running config: inbound <tag>: <reason>, which would end its live connections; restart to apply it |
The running configuration stays in place; restart to apply the change. |
| REST API | 422 with {"error": "<error>"} |
The configuration file is not written. See REST API. |
A start logs config loaded: … and a reload config reloaded: …, each followed by what it built, reused and changed. See Hot reload.
--test cannot catch problems that only exist when a socket is bound, such as a port already in use or a privileged port without the right capability. At startup such a problem stops the process, for example failed to start: inbound socks-in: binding 127.0.0.1:1080 failed: Address already in use (os error 98). On a reload, a listener that cannot be bound refuses the whole reload, and the running configuration, with all of its listeners, stays in place. Two inbounds with the same listen and port are caught by --test: inbound <tag>: 127.0.0.1:1080 is bound by another inbound.
Log lines, including these errors, go to standard output, as does Configuration OK..
Tags and the default route
Section titled “Tags and the default route”Every inbound, outbound and balancer has a tag. Rules, balancers and [route] default refer to outbounds by tag, and rules can match on the inbound tag.
| Rule | Error when broken |
|---|---|
| Inbound tags are unique among inbounds and not empty. | duplicate inbound tag <tag> |
| Outbound tags are unique among outbounds and not empty. | duplicate outbound tag <tag> |
| A balancer tag differs from every outbound tag and every other balancer tag, because a balancer can be used wherever an outbound can. | duplicate balancer tag … |
| There is somewhere to send traffic. | config defines no outbounds |
Every tag named in [route] default or a rule’s outbound exists, as an outbound or a balancer, or is direct or blackhole. |
route references unknown outbound <tag> |
Every tag in a balancer’s outbounds names an outbound. Another balancer is not accepted there. |
balancer <tag> references unknown outbound <member> |
Inbound and outbound tags live in separate namespaces, so an inbound and an outbound may share a tag. Two inbounds that both have users, such as two Trojan inbounds, and share a tag are reported as duplicate user set tag <tag>, because each inbound’s users are kept under the inbound’s tag.
direct and blackhole need no outbound block. When a route names one of them and no outbound or balancer carries that tag, etemenanki-app adds it: direct as a freedom outbound, blackhole as a blackhole outbound, after your own outbounds. An outbound of your own with that tag is used instead; with a subscribe file, only if it has that protocol.
The default route is where a flow goes when no rule matches:
- with
[subscribe], thedefaultpick in[subscribe.routes], if there is one; - otherwise, if
[route]setsdefault, that outbound or balancer; - otherwise, the first
[[outbound]]in the file (with[subscribe]and no outbound of your own, the first node).
A file without [route] therefore sends everything to its first outbound. When you add a blackhole or freedom outbound above your proxy outbound, set default explicitly, or all traffic will follow the new first entry.
Files the configuration reads
Section titled “Files the configuration reads”Some keys name files. etemenanki-app reads them while it checks the configuration, so --test fails if one is missing or unreadable.
| Key | Read when |
|---|---|
[subscribe] path |
Always, when [subscribe] is present. |
[inbound.stream.tls] cert_file, key_file |
The inbound’s stream uses TLS (network = "tls", or security = "tls" under ws or grpc). |
[outbound.stream.tls] ca_file |
The outbound’s stream uses TLS. |
[dns] ca_file |
When the key is set. |
[route] geosite |
Only when at least one rule or route group has a geosite condition. |
[route] geoip |
Only when at least one rule or route group has a geoip condition. |
Hysteria 2 inbound settings.cert_file, settings.key_file |
Always. |
Hysteria 2 outbound settings.ca_file |
When the key is set. |
| The system hosts file | The subscribe file’s [dns] sets use_hosts = true. |
A rule that uses geosite or geoip while the matching [route] key is missing fails with building route failed: a geosite matcher is used but no geosite file is configured (or the geoip equivalent). A file that is present but lacks a code a rule names fails with building route failed: geosite code not found: <code> or … geoip code not found: <code>.
Relative paths resolve against the process’s working directory, not against the config file’s directory. cert_file = "certs/server.pem" works when you run --test from the config directory and fails when a service manager starts the process from /. Use absolute paths.
Certificate, key and CA files are read at startup and on each reload. To put a renewed certificate into service, change the configuration file as well, for example with a comment that records the renewal date; see Hot reload.
Logging: [log]
Section titled “Logging: [log]”[log] has one key.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
level | string | no | "info" | A tracing EnvFilter directive, the same syntax as RUST_LOG: a level (off, error, warn, info, debug, trace, or a number from 0 to 5, case-insensitive), optionally followed by per-target overrides such as "warn,etemenanki_protocols=debug". A RUST_LOG variable that parses as a filter replaces this value, even an empty one, which enables nothing. The value is not validated: a word that is not a level, such as "warning", is read as a target name and silences every log line, errors included. An empty value, or one in which no directive parses, logs errors only. Read once at startup and not applied on reload. |
level is a filter directive in the syntax of the tracing crate’s EnvFilter, the same one RUST_LOG uses. A bare level applies to everything; target=level pairs, separated by commas, override it for one crate or module.
level |
Effect |
|---|---|
"info" (default) |
Startup, listeners, reloads, warnings and errors. |
"debug" |
Adds per-connection events, such as failed handshakes and refused connections. Verbose on a busy server. |
"warn,etemenanki_protocols=debug" |
Warnings and errors everywhere, debug output from the protocol implementations. |
"off" |
Nothing. |
The level is resolved once, at startup:
- If the
RUST_LOGenvironment variable is set and parses as a filter, it is used and[log] levelis ignored. An emptyRUST_LOGcounts as a valid filter that enables nothing. ARUST_LOGthat does not parse is ignored. - Otherwise, if the file parses, its
levelis used, orinfowhen the file has nolevel. - Otherwise,
infois used, so a TOML parse error is always printed.
A reload does not change the level. Restart the process to apply a new [log].
A complete annotated example
Section titled “A complete annotated example”This file exercises most sections: logging, DNS over HTTPS, two local inbounds, a VLESS and a Trojan outbound behind a failover balancer, direct and blackhole outbounds, and a few routing rules. It passes --test once geodata files that contain the category-ads-all and private codes exist at the two paths it names. Replace the placeholder server names, UUID and password with your own.
# A complete, annotated etemenanki-app configuration.## It runs a local gateway: SOCKS5 and HTTP proxies on the loopback interface,# traffic carried to a VLESS server over WebSocket + TLS, a Trojan server that# takes over when the VLESS server stops answering, and rules that block ads,# keep private addresses direct and refuse outgoing mail.## Check it before you use it:# etemenanki-app --test -c /etc/etemenanki/config.toml## etemenanki-app watches this file. A saved change is applied while it runs,# and open connections stay up unless the change removes their inbound or# their user. A change it refuses leaves the running configuration in place,# and the log says why.## Every key is spelled exactly as etemenanki-app expects it. An unknown key is# an error, not a silent no-op. Relative paths resolve against the working# directory of the process, not against this file, so paths here are absolute.
# ---------------------------------------------------------------------------# Logging# ---------------------------------------------------------------------------[log]# An EnvFilter directive: a level, optionally with per-target overrides such# as "info,etemenanki_protocols=debug". A RUST_LOG variable that parses as a# filter replaces it. Read at startup only: a reload does not change it.level = "info"
# ---------------------------------------------------------------------------# Name resolution# ---------------------------------------------------------------------------# Used for the outbound servers below, for "direct" destinations, for# WireGuard endpoints and for balancer probes. Leave the whole table out to# use the host resolver.[dns]backend = "https" # "system" | "udp" | "tls" | "https"server = "1.1.1.1:443" # an IP literal with a port, never a nameurl = "https://cloudflare-dns.com/dns-query"
# ---------------------------------------------------------------------------# Inbounds: where clients connect# ---------------------------------------------------------------------------# A table such as [inbound.settings] belongs to the closest [[inbound]] above# it, so keep each inbound's sub-tables directly under it.
[[inbound]]tag = "socks-in" # unique among inbounds; rules can match on itprotocol = "socks"listen = "127.0.0.1" # the default; write "0.0.0.0" to accept remote clientsport = 1080
[inbound.settings] # checked at build time, after the TOML parseauth = "none"udp = true
[[inbound]]tag = "http-in"protocol = "http"listen = "127.0.0.1"port = 8080sniffing = true # the default: for an IP destination, read the name from TLS SNI or HTTP Host
[inbound.settings]accounts = [{ user = "alice", pass = "replace-with-a-long-random-password" }]
# ---------------------------------------------------------------------------# Outbounds: where flows leave# ---------------------------------------------------------------------------# Without [route].default, the first [[outbound]] is the default route. This# file sets default = "auto" below, so the order here only affects the order# in which build errors are reported.
[[outbound]]tag = "vless-ws"protocol = "vless"server = "proxy.example.com"port = 443
[outbound.stream]network = "ws"security = "tls" # "tls" or "none"; any other value is an error
[outbound.stream.ws]path = "/ws"
[outbound.stream.tls]server_name = "proxy.example.com"
[outbound.settings]id = "11111111-2222-3333-4444-555555555555"
[[outbound]]tag = "trojan-tls"protocol = "trojan"server = "203.0.113.10"port = 443
[outbound.stream]network = "tls" # TLS over plain TCP; no security key needed
[outbound.stream.tls]server_name = "example.com" # the name the server certificate is checked against
[outbound.settings]password = "replace-with-a-long-random-password"
[[outbound]]tag = "direct"protocol = "freedom" # connect to the destination directly
[[outbound]]tag = "block"protocol = "blackhole" # accept the flow and drop everything
# ---------------------------------------------------------------------------# Balancers: several outbounds behind one tag# ---------------------------------------------------------------------------[[balancer]]tag = "auto" # must not repeat an outbound tagoutbounds = ["vless-ws", "trojan-tls"]strategy = "failover" # list order is priority; or "round_robin"probe_interval = 30 # seconds between TCP health probes (default 30)probe_timeout = 5 # seconds before a probe counts as failed (default 5)
# ---------------------------------------------------------------------------# Routing# ---------------------------------------------------------------------------[route]default = "auto" # an outbound or balancer tag# Each file is read only when a rule below uses a geoip or geosite condition.geoip = "/etc/etemenanki/geoip.dat"geosite = "/etc/etemenanki/geosite.dat"
# Rules are tried from top to bottom and the first match wins. Inside one# rule, the flow matches if ANY of the listed conditions matches: the second# rule below sends a flow direct when its address is private OR its name ends# in .lan. Conditions are never combined with AND.
[[route.rule]]outbound = "block"geosite = ["category-ads-all"]
[[route.rule]]outbound = "direct"geoip = ["private"]domain_suffix = ["lan"]
# Never relay outgoing mail. Ports are strings: "25", or a range "8000-9000".[[route.rule]]outbound = "block"port = ["25", "465", "587"]For a client that takes its servers from a provider, see the example on Subscribe files.
Common errors
Section titled “Common errors”| Error | Cause | Fix |
|---|---|---|
TOML parse error at line <n>, column <m> |
A syntax error, a misspelled key, a key in the wrong table, a plural array name, [inbound] with single brackets, or a value of the wrong type. |
Go to that line. Check the spelling of the key and that it sits under the right [...] header. |
inbound <tag>: invalid settings: … |
A problem inside that inbound’s [inbound.settings]. |
Read the rest of the message; it names the key. |
inbound <tag>: users[<n>] has no email; a user of this inbound is named by its email |
A Trojan, VLESS, VMess, Shadowsocks, AnyTLS or sss user without email. |
Give every user a unique email. |
config defines no outbounds |
Nothing to send traffic to: no [[outbound]], no subscribe file and no route that names direct or blackhole. |
Add an outbound, even if it is only freedom. |
route references unknown outbound <tag> |
[route] default or a rule’s outbound names a tag that is not defined, possibly in a different case. |
Define the outbound or balancer, or fix the spelling. |
outbound <tag>: unknown protocol "<value>" |
An unsupported or capitalised protocol name. | Use the lower-case name from Outbounds or Inbounds. |
subscribe: … |
A problem in the subscribe file, or in your picks. | See the errors on Subscribe files. |
[api] … |
A problem in [api], such as a public address without a secret. |
See REST API. |
… No such file or directory (os error 2) |
A file the configuration names does not exist, often a relative path resolved against the wrong directory. | Use absolute paths and check each one. |