配置文件
etemenanki-app 读取一个 TOML 文件。这个文件描述客户端从哪里接入(入站)、流量从哪里离开(出站)、每个流如何选择出站(路由),以及日志、DNS 等几项进程级设置。在客户端上,这个文件还可以指定一个提供服务器和路由的订阅文件,也可以开启 REST API。本页介绍文件的整体情况:结构、校验有多严格、会看到哪些错误,以及 [log] 表。文件中每一部分都有单独的页面,链接列在本页末尾。
第一次手写配置文件之前,或者 --test 拒绝了文件而错误信息又不够清楚时,请先阅读本页。
最小的可用配置是一个本地 SOCKS 代理,把所有流量直接发出:
[[inbound]]tag = "socks-in"protocol = "socks"listen = "127.0.0.1"port = 1080
[[outbound]]tag = "direct"protocol = "freedom"用 -c(长格式为 --config)指定文件。不指定时,etemenanki-app 读取当前工作目录下的 config.toml。用 --test 可以只检查文件、不启动任何东西:
etemenanki-app --test -c /etc/etemenanki/config.toml--test 会执行真正启动时的全部检查,并读取配置用到的所有文件(包括订阅文件),但不绑定任何监听器、不打开 TUN 设备,也不启动 API。成功时输出 Configuration OK.,退出状态为 0;失败时记录 configuration invalid: …,退出状态为 1。
-
编写或修改文件。
-
运行
etemenanki-app --test -c <file>。 -
如果失败,修正它指出的错误后再运行一次。每次只报告第一个错误,所以一个有三处错误的文件需要改三轮。
-
用
etemenanki-app -c <file>启动代理;如果代理已经在运行,直接保存文件即可,它会自动重载(见热重载)。
一个文件由八个顶层条目组成。对 TOML 解析器来说它们都是可选的。文件最终需要的是一个发送流量的去处:一个 [[outbound]]、订阅文件中的一个节点,或者一条引用 direct 或 blackhole 的路由。
| 键 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
log | table | 否 | {} | 日志设置,写作 [log],只有 level 一个键。见配置文件页面的 [log] 一节。 |
dns | table | 否 | {} | 代理服务器、WireGuard 端点、负载均衡器探测和 freedom 目标地址所用的域名解析,写作 [dns]。不写时,etemenanki-app 使用主机的系统解析器,并在其前面始终加一层缓存。如果 [subscribe] 指定的订阅文件有自己的 [dns],则改用订阅文件里的。 |
inbound | array of tables | 否 | [] | 监听器,每个 [[inbound]] 块一个。键名是单数:[[inbounds]] 会被当作未知字段。没有入站也能通过校验,只是进程不接受任何连接。入站之间的 tag 不能重复。 |
outbound | array of tables | 视情况 | — | 流量的出口,每个 [[outbound]] 块一个。键名是单数。出站之间的 tag 不能重复。除非 [route] 设置了 default,文件中第一个 [[outbound]] 就是默认路由。配置里至少要有一个出站(否则报 config defines no outbounds),但 direct 和 blackhole 不必写出站块:当路由引用了其中之一、而没有任何出站或负载均衡器使用这个 tag 时,etemenanki-app 会自动把它添加为 freedom 或 blackhole 出站。使用 [subscribe] 时,订阅文件里的节点会追加在配置自身的出站之后。 |
balancer | array of tables | 否 | [] | 一组可以互相替代的出站,每个 [[balancer]] 块一个。键名是单数。负载均衡器的 tag 可以用在任何接受出站 tag 的地方,因此不能与出站或其他负载均衡器的 tag 重复。 |
route | table | 否 | {} | 路由设置,写作 [route],规则写作 [[route.rule]] 块(单数;[[route.rules]] 会被当作未知字段)。第一条匹配的规则生效。不写 [route] 时,所有流都走第一个 [[outbound]]。使用 [subscribe] 时,规则改由订阅文件里的路由组生成。 |
subscribe | table | 否 | — | 提供客户端部分的订阅文件,写作 [subscribe]:文件里的节点成为出站,路由组成为路由规则;如果它有 [dns],就取代本文件的 [dns]。[subscribe.routes] 为每个路由组选择节点。所有 [[inbound]] 仍然来自本文件。 |
api | table | 否 | — | 通过修改本文件来切换路由组所用节点的 REST API,写作 [api]。不写时 API 不监听。 |
各部分之间的关系如下。虚线表示查询,而不是流量。
flowchart LR IN["[[inbound]]"] --> R["[route] 和 [[route.rule]]"] R --> OUT["[[outbound]]"] R --> BAL["[[balancer]]"] BAL --> OUT DNS["[dns]"] -.-> OUT DNS -.-> BAL SUB["[subscribe]"] -.->|"节点"| OUT SUB -.->|"路由组"| R SUB -.->|"它的 [dns]"| DNS API["[api]"] -.->|"修改选择"| SUB API -.->|"修改 default"| R
表数组与子表
Section titled “表数组与子表”inbound、outbound、balancer 和 route.rule 都是表数组:每个条目写一次带双层方括号的 [[inbound]]。这些名称是单数,尽管 Xray 的 JSON 把同样的列表写作 inbounds 和 outbounds。
| 写法 | 结果 |
|---|---|
[[inbound]] |
新增一个入站。 |
[[inbounds]] |
该行报解析错误:顶层键名是 inbound。 |
[inbound](单层方括号) |
该行报解析错误:inbound 是列表,要写成 [[inbound]]。[outbound]、[balancer] 和 [route.rule] 也一样。 |
[[route.rule]] |
新增一条路由规则。 |
[[route.rules]] |
该行报解析错误:键名是 rule。 |
[inbound.settings]、[inbound.stream]、[outbound.stream.tls] 这类嵌套表,属于它们上方最近的那个 [[inbound]] 或 [[outbound]]。这是 TOML 本身的规则,也是移动配置块时最容易犯的错误。
什么时候顺序有影响
Section titled “什么时候顺序有影响”各部分在文件中的位置无关紧要,但有两个例外:
[[outbound]]的顺序。[route]没有设置default时,第一个[[outbound]]就是默认路由。[[route.rule]]的顺序。 规则从上到下依次尝试,第一条匹配的规则生效。见路由。
使用 [subscribe] 时,订阅文件中的节点排在你自己的出站之后,它的路由组按文件中的顺序取代你的规则。文件中有多处错误时,顺序还决定先看到哪一个错误,见文件如何被检查。
严格是有意为之
Section titled “严格是有意为之”etemenanki-app 采用 fail closed(出错即拒绝):出了错,代理会报错停止,而不是悄悄改变行为。如果拼错的 listen 退回默认值,本应只在 localhost 上监听的代理可能暴露到网络上;如果拼错的 security 退回明文,凭据就会以明文发送。这两种情况都会被拒绝。
未知的键是错误
Section titled “未知的键是错误”文件中的每个表都会拒绝它不认识的键。这包括嵌套的 stream、tls、ws、grpc 和 reality 表,[subscribe] 和 [api],以及每个有设置项的协议的 settings 表。键名区分大小写,所以 Tag 和 lisen 一样都是未知键。settings 表之外拼错的键会让解析停止,错误会指出它的位置:
configuration invalid: TOML parse error at line 8, column 1整个配置结构中唯一的别名,是 Shadowsocks 入站 settings 中用 clients 代替 users,这是为了兼容 Xray。
未知的值是错误
Section titled “未知的值是错误”protocol、network、strategy 这样的值,对 TOML 解析器来说只是普通字符串。etemenanki-app 会把每个值与它支持的取值逐一比对,其他值一律报错,不会退回任何默认值。
这些比较大多是精确匹配、区分大小写的,少数几个比较宽松:
| 值 | 接受的写法 | 被拒绝的值示例 |
|---|---|---|
protocol(入站和出站) |
精确匹配,小写。别名:hysteria 和 hy2 表示 hysteria2;出站还可以用 direct 表示 freedom,用 block 表示 blackhole。 |
"Freedom" → outbound direct: unknown protocol "Freedom" |
[.stream] network |
精确匹配:tcp、tls、ws、grpc。 |
"WS" → inbound a: unknown stream network "WS" |
[.stream] security |
去掉首尾空格后精确匹配:tls、reality、none 或空值。network = "tcp" 时不接受 tls;TCP 上的 TLS 写作 network = "tls"。reality 需要 network = "tcp",并且只能用在 VLESS 入站或出站上。 |
"TLS" → inbound a: unknown stream security "TLS" (expected "tls" or "none") |
VLESS 的 flow |
精确匹配:xtls-rprx-vision 或空值。 |
"xtls-rprx-direct" → outbound p: unknown vless flow "xtls-rprx-direct" |
sss 的 reject |
精确匹配:"drain",或 { fallback = "ip:port" } 表。 |
"close" → inbound sss-in: reject is neither "drain" nor { fallback = "ip:port" } |
[[balancer]] strategy |
精确匹配:failover、round_robin。 |
"Failover" → balancer auto: unknown balancer strategy "Failover" (expected "failover" or "round_robin") |
[dns] backend |
精确匹配:system、udp、tls、https。 |
"UDP" → dns: unknown backend "UDP" (expected "system", "udp", "tls" or "https") |
[[route.rule]] network |
精确匹配:tcp、udp。 |
"TCP" → invalid rule network "TCP" (expected "tcp" or "udp") |
SOCKS 入站的 auth、Hysteria 2 的 obfs |
精确匹配。 | "Password" → inbound socks-in: unknown socks auth "Password" |
出站的 address_family、WireGuard 的 endpoint_address_family |
不区分大小写,去掉首尾空格,- 视同 _。 |
"ipv5" → outbound direct: invalid address_family "ipv5" |
VMess 出站的 security |
不区分大小写。 | "none" → outbound v: unknown vmess security "none" |
Shadowsocks 的 method |
AEAD 方法不区分大小写;2022- 方法精确匹配。 |
"2022-BLAKE3-AES-128-GCM" → inbound a: unknown shadowsocks-2022 method "2022-BLAKE3-AES-128-GCM" |
[log] level |
不区分大小写,但从不拒绝。见日志:[log]。 |
"warning" 会被接受,并让日志完全静默。 |
tag 同样精确比较:default = "home" 找不到 tag 为 "Home" 的出站。
文件如何被检查
Section titled “文件如何被检查”etemenanki-app 每次加载文件时,无论是 --test、启动、重载,还是 REST API 写入修改之前,都会执行同样的几个阶段。只有真正启动或重载时才会接着绑定监听器。
flowchart LR A["读取文件,以及它指定的订阅文件"] --> B["1. 解析"] B --> C["2. 降为 spec"] C --> D["3. 校验"] D --> E["4. 构建"] E --> T["--test:Configuration OK."] E --> S["启动或重载:绑定监听器,打开 TUN 设备"] B & C & D & E -->|"第一个错误"| X["拒绝"]
| 阶段 | 检查内容 | 错误的样子 |
|---|---|---|
| 1. 解析 | TOML 语法、UTF-8、未知的键、值的类型(该写数字的地方写了字符串、端口大于 65535)、tag 和 protocol 等必填键。订阅文件也在这里解析。 |
TOML parse error at line <n>, column <m>,或 subscribe: TOML parse error at line <n>, column <m> |
| 2. lowering(降为 spec) | 每个 settings 表;每个枚举值;有自己语法的字符串(UUID、密钥、CIDR、端口、正则表达式、DNS 服务器);配置指定的文件;没有名字或重名的用户;没有意义的键组合;订阅文件的合并;[api] |
inbound <tag>: …、outbound <tag>: …、balancer <tag>: …、dns: …、subscribe: …、[api] …、invalid cidr … |
| 3. 校验 | tag(唯一且不为空)以及规则和负载均衡器引用的 tag;负载均衡器成员;两个入站使用同一地址和端口;两个用户出示同一凭据;各种上限和密钥长度 | duplicate inbound tag <tag>、route references unknown outbound <tag>、inbound <tag>: …、outbound <tag>@v0: … |
| 4. 构建 | 像启动时那样构建所有东西,但不绑定:解析器、每个出站和负载均衡器、路由表及其用到的 geodata,以及每个入站的处理器(handler)和证书 | building <what> failed: …,例如 building route failed: … 或 building inbound socks-in failed: … |
第 2 和第 3 阶段内部的顺序是固定的,第一个错误就会让检查停止。lowering 先处理 [dns],然后按文件顺序处理每个 [[outbound]]、每个 [[balancer]]、[route],最后是每个 [[inbound]]。校验先检查各个 tag,然后是每个出站、负载均衡器、路由的引用,最后是每个入站。因此,即使出错的入站在文件中排在前面,出错的规则也会先被报告;格式错误的 UUID 也会先于重复的 tag 被报告。
settings 表中的错误
Section titled “settings 表中的错误”settings 表在 lowering 阶段检查,所以它的错误不带行号,而是指明对象,形如 inbound <tag>: invalid settings: … 或 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`在文件中搜索消息里的 tag,就能找到对应的表。
错误出现在哪里
Section titled “错误出现在哪里”错误文本在各种情况下都相同,只是外面的那一行不同:
| 情况 | 日志行 | 结果 |
|---|---|---|
etemenanki-app --test |
configuration invalid: <error> |
以状态 1 退出。 |
| 启动 | failed to start: <error> |
以状态 1 退出。 |
| 重载 | reload: <error>; keeping the running config |
正在运行的配置保持不变。 |
| 重载的修改会结束现有连接,例如修改 TUN | reload refused, keeping the running config: inbound <tag>: <reason>, which would end its live connections; restart to apply it |
正在运行的配置保持不变;重启才能应用这项修改。 |
| REST API | 422 和 {"error": "<error>"} |
配置文件不会被写入。见 REST API。 |
启动时记录 config loaded: …,重载时记录 config reloaded: …,后面列出新建、复用和修改了哪些东西。见热重载。
--test 发现不了只有绑定 socket 时才会出现的问题,例如端口已被占用,或者没有相应权限却使用特权端口。启动时这类问题会让进程停止,例如 failed to start: inbound socks-in: binding 127.0.0.1:1080 failed: Address already in use (os error 98)。重载时,只要有一个监听器无法绑定,整次重载都会被拒绝,正在运行的配置连同它的所有监听器保持不变。两个入站使用相同的 listen 和 port,--test 就能发现:inbound <tag>: 127.0.0.1:1080 is bound by another inbound。
日志行(包括这些错误)以及 Configuration OK. 都输出到标准输出。
tag 与默认路由
Section titled “tag 与默认路由”每个入站、出站和负载均衡器都有一个 tag。规则、负载均衡器和 [route] default 通过 tag 引用出站,规则也可以按入站的 tag 匹配。
| 规则 | 违反时的错误 |
|---|---|
| 入站的 tag 在所有入站中唯一,且不为空。 | duplicate inbound tag <tag> |
| 出站的 tag 在所有出站中唯一,且不为空。 | duplicate outbound tag <tag> |
| 负载均衡器的 tag 与所有出站的 tag 以及其他负载均衡器的 tag 都不同,因为凡是能用出站的地方都能用负载均衡器。 | duplicate balancer tag … |
| 流量有去处。 | config defines no outbounds |
[route] default 或规则的 outbound 中写的每个 tag 都存在,可以是出站或负载均衡器,也可以是 direct 或 blackhole。 |
route references unknown outbound <tag> |
负载均衡器 outbounds 中的每个 tag 都对应一个出站。这里不接受另一个负载均衡器。 |
balancer <tag> references unknown outbound <member> |
入站和出站的 tag 位于不同的命名空间,所以一个入站和一个出站可以使用同一个 tag。两个都带有用户的入站(例如两个 Trojan 入站)使用同一个 tag 时,会报 duplicate user set tag <tag>,因为每个入站的用户都以该入站的 tag 保存。
direct 和 blackhole 不需要出站块。当路由引用其中之一、而没有任何出站或负载均衡器使用这个 tag 时,etemenanki-app 会把它加在你自己的出站之后:direct 作为 freedom 出站,blackhole 作为 blackhole 出站。如果你自己有使用这个 tag 的出站,就改用它;使用订阅文件时,只有协议相符才行。
默认路由是没有规则匹配时流的去向:
- 使用
[subscribe]时,如果[subscribe.routes]中有default选择,就用它; - 否则,如果
[route]设置了default,就用那个出站或负载均衡器; - 否则,用文件中的第一个
[[outbound]](使用[subscribe]而自己没有出站时,用第一个节点)。
因此,没有 [route] 的文件会把所有流量发往第一个出站。如果你在代理出站之前加了一个 blackhole 或 freedom 出站,请显式设置 default,否则所有流量都会跟着新的第一个条目走。
配置读取的文件
Section titled “配置读取的文件”有些键指定的是文件。etemenanki-app 在检查配置时读取它们,所以只要其中一个缺失或无法读取,--test 就会失败。
| 键 | 何时读取 |
|---|---|
[subscribe] path |
只要有 [subscribe] 就读取。 |
[inbound.stream.tls] cert_file、key_file |
入站的 stream 使用 TLS 时(network = "tls",或 ws、grpc 下的 security = "tls")。 |
[outbound.stream.tls] ca_file |
出站的 stream 使用 TLS 时。 |
[dns] ca_file |
设置了这个键时。 |
[route] geosite |
只有至少一条规则或一个路由组使用 geosite 条件时。 |
[route] geoip |
只有至少一条规则或一个路由组使用 geoip 条件时。 |
Hysteria 2 入站的 settings.cert_file、settings.key_file |
总是读取。 |
Hysteria 2 出站的 settings.ca_file |
设置了这个键时。 |
| 系统 hosts 文件 | 订阅文件的 [dns] 设置了 use_hosts = true 时。 |
规则用到了 geosite 或 geoip,而 [route] 中缺少对应的键时,报 building route failed: a geosite matcher is used but no geosite file is configured(或 geoip 的同类错误)。文件存在但缺少规则引用的 code 时,报 building route failed: geosite code not found: <code> 或 … geoip code not found: <code>。
相对路径按进程的工作目录解析,而不是配置文件所在的目录。 cert_file = "certs/server.pem" 在配置目录下运行 --test 时能用,但由服务管理器从 / 启动进程时就会失败。请使用绝对路径。
证书、私钥和 CA 文件在启动时和每次重载时读取。要让续期后的证书生效,请同时修改配置文件,例如用一行注释记下续期日期;见热重载。
日志:[log]
Section titled “日志:[log]”[log] 只有一个键。
| 键 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
level | string | 否 | "info" | 一条 tracing 的 EnvFilter 指令,语法与 RUST_LOG 相同:一个级别(off、error、warn、info、debug、trace,或 0 到 5 的数字,不区分大小写),后面可以跟按 target 覆盖的级别,例如 "warn,etemenanki_protocols=debug"。环境变量 RUST_LOG 只要能解析为过滤器,就会取代这个值;设为空字符串也算合法,结果是什么都不输出。这个值不做校验:不是级别的词(例如 "warning")会被当成 target 名,结果是所有日志(包括错误)都不再输出。值为空,或者没有一条指令能解析时,只输出错误日志。只在启动时读取一次,热重载时不生效。 |
level 是一条 tracing crate 的 EnvFilter 过滤指令,语法与 RUST_LOG 相同。单独一个级别对所有内容生效;用逗号分隔的 target=level 对可以为某个 crate 或模块单独覆盖级别。
level |
效果 |
|---|---|
"info"(默认) |
启动、监听器、重载、警告和错误。 |
"debug" |
另外输出每个连接的事件,例如握手失败和被拒绝的连接。繁忙的服务器上会很啰嗦。 |
"warn,etemenanki_protocols=debug" |
各处只输出警告和错误,协议实现输出 debug 信息。 |
"off" |
什么都不输出。 |
级别在启动时确定一次:
- 如果设置了环境变量
RUST_LOG,并且它能解析为过滤器,就使用它,忽略[log] level。空的RUST_LOG算作合法的过滤器,结果是什么都不输出。无法解析的RUST_LOG会被忽略。 - 否则,如果文件能够解析,就使用其中的
level;文件没有level时使用info。 - 否则使用
info,所以 TOML 解析错误总会被输出。
重载不会改变日志级别。要应用新的 [log],请重启进程。
完整的注释示例
Section titled “完整的注释示例”下面的文件用到了大部分配置段:日志、DNS over HTTPS、两个本地入站、放在 failover 负载均衡器后面的一个 VLESS 出站和一个 Trojan 出站、direct 和 blackhole 出站,以及几条路由规则。只要它指定的两个路径上存在包含 category-ads-all 和 private 这两个 code 的 geodata 文件,它就能通过 --test。请把其中的占位服务器名、UUID 和密码换成你自己的。
# 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"]从服务商获取服务器的客户端,请看订阅文件中的示例。
| 错误 | 原因 | 解决办法 |
|---|---|---|
TOML parse error at line <n>, column <m> |
语法错误、拼错的键、键放在了错误的表中、数组名写成了复数、用单层方括号写 [inbound],或者值的类型不对。 |
转到那一行。检查键的拼写,以及它是否位于正确的 [...] 表头之下。 |
inbound <tag>: invalid settings: … |
该入站的 [inbound.settings] 里有问题。 |
阅读消息的其余部分,它会指出是哪个键。 |
inbound <tag>: users[<n>] has no email; a user of this inbound is named by its email |
Trojan、VLESS、VMess、Shadowsocks、AnyTLS 或 sss 的某个用户没有 email。 |
为每个用户设置一个不重复的 email。 |
config defines no outbounds |
流量没有去处:没有 [[outbound]]、没有订阅文件,也没有引用 direct 或 blackhole 的路由。 |
添加一个出站,哪怕只是 freedom。 |
route references unknown outbound <tag> |
[route] default 或规则的 outbound 引用了未定义的 tag,可能是大小写不同。 |
定义这个出站或负载均衡器,或者修正拼写。 |
outbound <tag>: unknown protocol "<value>" |
不支持的协议名,或者协议名用了大写。 | 使用出站或入站页面中列出的小写名称。 |
subscribe: … |
订阅文件或你的选择有问题。 | 见订阅文件中的错误列表。 |
[api] … |
[api] 有问题,例如公网地址没有设置密钥。 |
见 REST API。 |
… No such file or directory (os error 2) |
配置指定的某个文件不存在,通常是相对路径按错误的目录解析了。 | 使用绝对路径,并逐一检查。 |