Hysteria 2 节点
Hysteria 2 節點在一個 UDP 埠上透過 QUIC 承載代理流量。當節點的 [node.api].node_type 為 Hysteria2(也接受 hysteria、hy2,不區分大小寫)時,或者在不設定 node_type 的 helium 上,當面板的節點設定寫明 hysteria2 時,katana 就會提供這種節點。和其他節點一樣,使用者仍由面板下達,流量也仍回報給面板。在 Xboard 和 V2board 上,監聽器本身需要幾項面板不會下達的設定,所以它們放在節點的 [node.hysteria] 表中。除擁塞控制外,helium 會描述所有這些設定;見面板描述的節點。
本页介绍运行这种节点的两种方式:由面板描述节点,或由 katana 根据配置文件描述节点。本页列出 [node.hysteria] 下的所有键、面板必须下发的内容、官方 Hysteria 2 客户端如何认证,以及可能遇到的错误。关于 etemenanki-app 所提供的协议本身,见 etemenanki-app 中的 Hysteria 2。
Hysteria 2 节点有何不同
Section titled “Hysteria 2 节点有何不同”- 它监听 UDP。 katana 把
listen_ip:port绑定为 UDP 套接字,因此 Hysteria 2 节点可以与同一地址上的 TCP 节点共用端口号,例如 TCP 443 上的 Trojan 节点和 UDP 443 上的 Hysteria 2 节点。 - 它总是使用 TLS。 TLS 握手是 QUIC 的一部分,因此没有明文模式。无论面板对 TLS 怎么设置,每个 Hysteria 2 节点都需要
mode = "file"的[node.controller.cert]。 - 它的用户列表原地更新。 面板的用户列表变化时,UDP 套接字保持绑定,其余用户保持连接;被移除用户的连接会结束。
--test可以檢查它。[node.hysteria]下的設定都是本地的,所以katana --test會檢查它們,並讀取憑證和私鑰。對於其他節點型別,--test無法檢查面板將要下達的內容。helium 的 Hysteria 2 節點也屬於這一類:--test只檢查它的congestion,並拒絕[node.hysteria]中的其他所有鍵。
描述节点的两种方式
Section titled “描述节点的两种方式”在 Xboard 和 V2board 上,鍵 [node.hysteria].port 決定節點的埠和混淆設定從哪裡來。helium 節點總是由面板描述,在那裡 [node.hysteria].port 會被拒絕:
flowchart LR
A["node_type = Hysteria2"] --> B{"[node.hysteria] port"}
B -->|"0"| C["面板节点配置:port、obfs"]
B -->|"非零"| D["[node.hysteria]:port、obfs"]
C --> L["QUIC 监听器"]
D --> L
E["[node.hysteria]:credential、udp、masquerade、congestion"] --> L
F["[node.controller.cert]"] --> L
G["面板用户列表"] --> L
面板描述(port = 0) |
本地描述(port 非零) |
helium | |
|---|---|---|---|
| 監聽埠 | 面板的埠 | [node.hysteria].port |
面板的 port |
| 混淆 | 面板的 obfs 和 obfs-password |
[node.hysteria].obfs 和 obfs_password |
面板的 obfs |
速率(up_mbps、down_mbps、ignore_client_bandwidth) |
面板的值,[node.hysteria] 中設定了的項會覆蓋它 |
只取 [node.hysteria] |
只取面板的值 |
節點設定請求(/UniProxy/config、helium 的 config) |
每次輪詢都發送 | 從不傳送 | 每次輪詢都發送 |
| 使用者列表和流量回報 | 從面板取得,回報到面板 | 從面板取得,回報到面板 | 從面板取得,回報到面板 |
來自節點 routes 的審計規則(Xboard) |
載入 | 不載入;只有 rule_list_path 生效 |
面板不下達;只有 rule_list_path 生效 |
UDP 中繼(udp、udp_idle_timeout)和偽裝回應 |
[node.hysteria] |
[node.hysteria] |
面板的 udp 和 masquerade |
credential |
[node.hysteria] |
[node.hysteria] |
始終是 UUID |
congestion |
[node.hysteria] |
[node.hysteria] |
[node.hysteria] |
如果你希望把埠和混淆設定保存在設定檔裡,而不是面板中,就在本地描述節點。面板仍然必須知道這個節點:katana 會向面板請求 node_id 的使用者,並以該 ID 回報他們的流量。在 Xboard 上,尋找節點還會用到節點型別,所以該節點在面板中必須以 Hysteria 節點的形式存在。
本地描述的节点
Section titled “本地描述的节点”下面的文件在 UDP 端口 443 上提供一个 Hysteria 2 节点,启用 Salamander 混淆和 UDP 中继。用户和流量上报都经由一个 Xboard 面板。
# katana Hysteria 2 node described locally: the port and the obfuscation# come from [node.hysteria], so katana never asks the panel for the node's# config. The panel still supplies the user list and receives the traffic# reports for node_id 1.
[log]level = "info"
[[node]]panel_type = "NewV2board"
[node.api]host = "https://panel.example.com"node_id = 1key = "replace-with-the-panel-key"# Sent to the panel as node_type=hysteria2, which Xboard maps to its# "hysteria" node type.node_type = "Hysteria2"
[node.controller]listen_ip = "0.0.0.0"update_periodic = 60
# Every Hysteria 2 node needs a certificate file. Clients that verify it# also need a subjectAltName for the name they use as SNI.[node.controller.cert]mode = "file"cert_file = "/etc/katana/cert/fullchain.pem"key_file = "/etc/katana/cert/privkey.pem"
[node.hysteria]# Non-zero: this node is described here. Clients connect to UDP port 443.port = 443# The client's auth string is the user's UUID (the default).credential = "uuid"# Relay UDP as well as TCP; a quiet UDP session ends after 60 seconds.udp = trueudp_idle_timeout = 60# Salamander obfuscation. Clients need the same password.obfs = "salamander"obfs_password = "replace-with-a-long-random-password"# Answer clients "auto": no fixed rate either way, and Cubic congestion# control (both the defaults). With ignore_client_bandwidth = false, a client# that declares its download rate is sent to at that rate, up to up_mbps.ignore_client_bandwidth = truecongestion = "cubic"
# What anyone without a valid credential sees.[node.hysteria.masquerade]status = 404body = "<html><body><h1>404 Not Found</h1></body></html>\n"content_type = "text/html; charset=utf-8"-
检查文件。
--test会读取证书和私钥,并检查[node.hysteria]下的每个键。它不会联系面板。终端窗口 katana --test -c /etc/katana/config.toml文件有效时打印
Configuration OK并以状态0退出。文件无效时把原因打印到 stderr,并以状态1退出:configuration error: node 1: udp_idle_timeout must be between 2 and 600 seconds -
启动 katana。 面板返回用户列表后,节点绑定套接字,并记录实际绑定的地址;在双栈主机上是
[::](见节点):INFO katana::manager::node: node 1: listening on [::]:443如果节点无法启动,例如面板无法访问或端口已被占用,katana 会记录原因并重试。常见错误列出了这些消息。
-
放行端口。 在主机防火墙和云安全组中放行入站 UDP 443。TCP 443 的规则不覆盖它。
-
连接客户端。 把用户的 UUID 作为认证字符串交给客户端,同时提供混淆密码和证书上的服务器名称。客户端认证中有完整的客户端配置。
如果要改由面板描述同一个节点,把 port 设为 0(或省略),并删除 obfs 和 obfs_password:
[node.hysteria]port = 0udp = true[node.hysteria]
Section titled “[node.hysteria]”在 node_type 是 Hysteria 2 取值的節點上,katana 用這個表建立 Hysteria 2 監聽器。--test 和熱重載對每個節點都檢查 congestion,無論節點是什麼型別。在 helium 節點上只能設定 congestion:其餘部分由 helium 的節點設定描述,下面的其他鍵都會被拒絕,見面板描述的節點中的 helium 標籤頁。未知鍵會被拒絕,因此像 obsf 這樣的拼寫錯誤會讓 --test 報一個指明所在行的解析錯誤並停止。
| 键 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
port | u16 | 否 | 0 | 監聽的 UDP 埠。非零值表示這是一個本地描述的節點:katana 用本表構造節點,從不呼叫面板的節點設定介面。0 表示像其他節點型別一樣,向面板取得埠和混淆設定。helium 節點會拒絕它:helium 節點總是由面板描述。 |
credential | string (enum) | 否 | "" | 客戶端的認證字串如何標識使用者。"" 或 uuid:整個字串就是使用者的 UUID。user_pass:字串為 label:uuid,按第一個冒號拆分,其中 label 在 Xboard 和 V2board 上是 <uuid>@v2board.user;label 比較時不區分大小寫。本項的取值本身區分大小寫;其他值報 unknown hysteria credential kind "…" (expected "uuid" or "user_pass")。helium 節點會拒絕這個鍵,所以它的使用者只用 UUID 認證。 |
udp | bool | 否 | false | 除 TCP 外也中繼 UDP。預設關閉,這一點與上游伺服端不同:此時監聽器會告訴客戶端 UDP 已停用,只中繼 TCP。helium 節點會拒絕它:是否中繼 UDP 由面板的 udp 決定。 |
udp_idle_timeout | u64 | 否 | 60 | UDP 會話在多少秒內沒有資料報就被 katana 關閉。取值範圍 2 到 600(超出時出現 udp_idle_timeout must be between 2 and 600 seconds)。預設值 60 只在 udp = true 時適用:這個鍵只在開啟 UDP 時有效,udp 關閉時設定它會出現 udp_idle_timeout is set but udp is not enabled。helium 節點會拒絕它:逾時由面板的 udp.idle_timeout_secs 設定,取值範圍相同。 |
obfs | string (enum) | 否 | — | 本地描述節點的封包混淆。唯一可接受的值是小寫的 salamander;其他值報 unknown obfs "…" (expected "salamander")。port = 0 時改用面板下達的混淆設定。helium 節點會拒絕它:混淆由面板的 obfs 設定。 |
obfs_password | string | 视情况 | — | 與所有客戶端共享的 Salamander 金鑰,至少 4 位元組(否則出現 obfs_password must be at least 4 bytes for salamander)。設定了 obfs 時必填。只設定它而不設定 obfs 會被拒絕,報 obfs_password is set but obfs is not; did you mean obfs = "salamander"?,這樣拼寫錯誤不會悄悄關閉混淆。與 obfs 一樣只用於本地描述的節點,helium 節點同樣會拒絕它。 |
masquerade | table | 否 | {} | 對所有未攜帶有效憑據的請求返回的 HTTP/3 回應,寫作 [node.hysteria.masquerade]。適用於本地描述的節點,以及由 Xboard 或 V2board 描述的節點。helium 節點會拒絕這張表中的任何鍵:應答由面板的 masquerade 設定。 |
up_mbps | u64 | 否 | — | 節點向單個客戶端傳送的最高速率,單位 Mbit/s。覆蓋面板的 up_mbps。0 表示不設上限。只有在與客戶端商定固定速率時才會用到,也就是 ignore_client_bandwidth 最終為 false 時。helium 節點會拒絕它:使用面板的 up_mbps。 |
down_mbps | u64 | 否 | — | 節點接收的最高速率,單位 Mbit/s,會在握手應答裡告訴每個客戶端。覆蓋面板的 down_mbps。0 表示不限制。helium 節點會拒絕它:使用面板的 down_mbps。 |
ignore_client_bandwidth | bool | 否 | — | 對每個客戶端都應答 auto,兩端都不按固定速率傳送,而是使用 congestion。覆蓋面板的值。本地和麵板都沒有設定時為 true。設為 false 時,宣告瞭下載速率的客戶端會按該速率接收資料,上限為 up_mbps。helium 節點會拒絕它:使用面板的 ignore_client_bandwidth,面板不寫時為 true。 |
congestion | string (enum) | 否 | "cubic" | 沒有商定固定速率時使用的擁塞控制:小寫的 cubic、bbr 或 reno。其他值在 --test 時出現 unknown hysteria congestion "…" (expected "cubic", "bbr" or "reno"),無論節點是不是 Hysteria 2。面板不會下達此項。這是本表中 helium 節點唯一可以設定的鍵。 |
[node.hysteria.masquerade]
Section titled “[node.hysteria.masquerade]”Hysteria 2 伺服端看起來像一個 HTTP/3 Web 伺服器。憑據錯誤或缺失的請求,或者指向任何其他路徑的請求,都會得到這個固定回應,因此密碼錯誤看起來和 URL 錯誤完全一樣。省略這個表,或只設定其中部分鍵時,缺失的鍵取下面的預設值。這些預設值與未設定的上游伺服端的回覆一致。在 helium 上改由面板的 masquerade 給出回應,這個表會被拒絕。
| 键 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
status | u16 | 否 | 404 | HTTP 狀態碼。100 到 999 之間的任意值都可以,但 233 除外:它是 Hysteria 2 的認證成功狀態碼,會讓探測者以為自己已經通過認證(報 masquerade.status must not be 233, the Hysteria 2 authentication success status)。超出範圍的值報 masquerade.status is <code>, but must be 100 to 999。 |
body | string | 否 | "404 page not found\n" | 响应正文,原样发送,并带有相应的 Content-Length。 |
content_type | string | 否 | "text/plain; charset=utf-8" | Content-Type 头的值。 |
katana 只在 QUIC 内部提供伪装响应,不会为它打开 TCP 监听器。启用 Salamander 时,没有混淆密码的客户端无法完成 QUIC 握手,所以根本到不了伪装响应。
证书来自节点的 [node.controller.cert],从不来自面板。对于 Hysteria 2 节点:
| 键 | 要求 |
|---|---|
mode |
必须为 "file"。默认值 "none" 以及 ACME 模式 "dns"、"http" 和 "tls" 都会报 hysteria2 node requires cert.mode = "file"。 |
cert_file |
PEM 证书链,叶子证书在前。两个路径都必须设置,否则节点报 TLS node requires cert.cert_file and cert.key_file。DER 文件会报 hysteria2: the certificate file contains no certificates。 |
key_file |
与证书匹配的 PEM 私钥,格式为 PKCS#8、PKCS#1 或 SEC1。 |
reject_unknown_sni |
必须保持 false。设为 true 会报 node requests kernel-unsupported feature: cert.reject_unknown_sni。 |
监听器只使用 TLS 1.3,并提供 ALPN h3。
katana 在节点启动时读取这些文件,此后每次轮询都会重新读取,所以保存到相同路径的续期证书会在下一次轮询时用于新连接,已打开的连接照常继续。请一步替换证书和私钥,这样 katana 不会只读到其中一个。
面板描述的节点
Section titled “面板描述的节点”port = 0 時,katana 每次輪詢都從面板取得埠和混淆設定;在 Xboard 和 V2board 上還取得速率 up_mbps、down_mbps 和 ignore_client_bandwidth(見 速率與擁塞控制)。在節點總是由面板描述的 helium 上,面板還下達 UDP 中繼和偽裝回應。面板下達的其他節點資訊 katana 都不使用:TLS 設定、伺服器名稱和埠跳躍設定對監聽器都沒有影響。埠跳躍是客戶端功能;在伺服端,用防火牆規則把埠範圍轉發到節點埠即可。因此,Xboard 上節點的 host 或 server_name 變化不會改變節點上的任何東西。
在面板中创建一个类型为 Hysteria 的节点,并把协议版本设为 2。katana 从 GET /api/v1/server/UniProxy/config 读取以下字段:
| 字段 | 面板设置 | katana 的用途 |
|---|---|---|
server_port |
節點的監聽埠(不是展示給使用者的埠) | UDP 埠,1 到 65535。其他任何值(包括 0)都會讓節點被拒絕:server_port 0 is not a port (1 to 65535)。 |
obfs |
开启混淆时为 salamander,关闭时为 null |
混淆类型 |
obfs-password |
混淆密码 | Salamander 密钥 |
up_mbps、down_mbps |
上行和下行带宽 | 节点的速率。Xboard 不发送 ignore_client_bandwidth,所以只有设置了 [node.hysteria] ignore_client_bandwidth = false 时它们才生效。 |
在 katana 配置中设置 panel_type = "NewV2board",以及 node_type = "Hysteria2" 或 "hysteria"。katana 会把 node_type 转为小写后发给面板,Xboard 会把 hysteria2 映射为它的 hysteria 类型。Xboard 不认识 hy2,所以按这种方式配置的节点发出的每个请求都会被拒绝。
Xboard 的订阅链接把用户的 UUID 作为 Hysteria 2 密码,这与 katana 默认的 credential 一致。
除擁塞控制外,helium 的節點設定描述整個監聽器。katana 從 protocol 為 hysteria2 的設定中讀取以下欄位:
| 欄位 | 含義 |
|---|---|
port |
UDP 埠。 |
obfs |
{"type": "salamander", "password": "…"},密碼至少 4 位元組。省略時封包以普通 QUIC 傳送。 |
up_mbps、down_mbps |
速率,單位 Mbit/s,兩者都必填,取整數。0 表示不設上限、不限制。 |
ignore_client_bandwidth |
省略時為 true。 |
udp |
{"idle_timeout_secs": 60}:節點中繼 UDP,會話安靜這麼多秒後關閉,取值 2 到 600,省略 idle_timeout_secs 時為 60。沒有 udp 時節點只中繼 TCP。 |
masquerade |
{"status": 404, "body": "…", "content_type": "…"},對未攜帶有效憑據的請求返回的回應:狀態碼在 100 到 999 之間,且不能是 233。省略時,節點的應答與省略 [node.hysteria.masquerade] 時相同。 |
{"protocol":"hysteria2","port":443,"obfs":{"type":"salamander","password":"replace-with-a-long-random-password"},"up_mbps":100,"down_mbps":100,"ignore_client_bandwidth":true,"udp":{"idle_timeout_secs":60}}違反其中任何一條規則的設定都無法解析,會出現 parse helium config response。
在 katana 設定中設定 panel_type = "Helium",不設定 node_type。[node.hysteria] 中只能設定 congestion。其他任何鍵(包括 port),以及 [node.hysteria.masquerade] 中的任何鍵,都會讓節點在 --test、啟動和熱重載時被拒絕,並指明是哪個鍵:
configuration error: node 1: [node.hysteria] udp is set, but a helium node's protocol is described by the panel; remove it (of [node.hysteria], only congestion is this host's to choose)[[node]]panel_type = "Helium"
[node.api]host = "https://panel.example.com"node_id = 1key = "replace-with-the-panel-key"
[node.controller.cert]mode = "file"cert_file = "/etc/katana/fullchain.pem"key_file = "/etc/katana/privkey.pem"
[node.hysteria]congestion = "bbr"katana 在讀取應答時檢查面板下達的值,規則與本地鍵相同:salamander 以外的任何型別報 unknown obfs,金鑰過短報 obfs_password must be at least 4 bytes for salamander。在 Xboard 和 V2board 上,拒絕會記錄在 parse UniProxy config response: 之後,例如 node 1: node_info failed: parse UniProxy config response: unknown obfs "x" (expected "salamander"); retrying in 1s。helium 的 UDP 中繼和偽裝回應同樣按 udp_idle_timeout 和 [node.hysteria.masquerade] 的規則檢查。本地的 obfs 和 obfs_password 鍵只用於本地描述的節點;--test 和重載檢查仍會檢查它們。
Hysteria 2 客户端发送一个认证字符串。[node.hysteria].credential 决定 katana 如何从中找出用户:
credential |
Xboard / V2board 上的認證字串 |
|---|---|
"" 或 "uuid"(預設) |
<uuid> |
"user_pass" |
<uuid>@v2board.user:<uuid> |
- 在
uuid模式下,整个字符串会与面板列出的每个用户的 UUID 逐字节比较,因此大小写有影响。除非你的客户端是按上游的userpass认证方式配置的,否则使用这种模式。 - 在
user_pass模式下,katana 在第一個冒號處拆分字串。冒號之前是使用者的標籤,比較時不區分大小寫:在 UniProxy 面板上是<uuid>@v2board.user。冒號之後是 UUID。這正是上游伺服端的userpass格式,所以為上游伺服端寫的客戶端設定無需改動即可使用。 - 两种模式下,katana 都按用户在面板中的 ID 上报其流量。
- 在 helium 上不能設定
credential,因此始終是uuid模式。katana 把來自 helium 的每個 UUID 寫成小寫帶連字元的形式,例如11111111-2222-3333-4444-555555555555,客戶端傳送的認證字串就是它。
认证字符串错误时会得到伪装响应。官方客户端随后会报告伪装响应的状态码,例如 authentication error, HTTP status code: 404。
server: proxy.example.com:443auth: 11111111-2222-3333-4444-555555555555obfs: type: salamander salamander: password: replace-with-a-long-random-passwordtls: sni: proxy.example.comsocks5: listen: 127.0.0.1:1080server: proxy.example.com:443auth: 11111111-2222-3333-4444-555555555555@v2board.user:11111111-2222-3333-4444-555555555555obfs: type: salamander salamander: password: replace-with-a-long-random-passwordtls: sni: proxy.example.comsocks5: listen: 127.0.0.1:1080节点没有混淆时,省略 obfs 块。混淆设置与节点不一致的客户端永远无法完成 QUIC 握手,它报告的是超时,而不是认证错误。
UDP 中继
Section titled “UDP 中继”udp 預設關閉。此時 katana 會在認證回覆中告訴每個客戶端 UDP 不可用,並且只中繼 TCP。上游伺服端預設啟用 UDP,所以如果你的使用者需要 UDP,請設定 udp = true。開啟 UDP 後,如果某個 UDP 會話在 udp_idle_timeout 秒內沒有任何資料報,katana 會將其關閉;這項檢查每秒進行一次。在 helium 上,面板的 udp 開啟中繼,其中的 idle_timeout_secs 就是空閒逾時。
速率与拥塞控制
Section titled “速率与拥塞控制”Hysteria 2 客戶端在認證請求中告訴伺服端自己能以多大速率接收。伺服端應答自己能以多大速率接收,或者應答 auto。兩端商定了速率時,傳送方使用 Hysteria 的 Brutal 擁塞控制,無論丟包多少都按該速率傳送;否則兩端都使用普通的擁塞控制。katana 根據三個值決定自己這一側,每個值在 [node.hysteria] 中設定了就取本地的,否則取面板的;在 helium 上只取面板的:
| 值 | 默认值 | 含义 |
|---|---|---|
ignore_client_bandwidth |
true |
应答 auto:两个方向都不使用固定速率 |
up_mbps |
0,不设上限 |
katana 向单个客户端发送的最高速率 |
down_mbps |
0,不限制 |
katana 告诉客户端的接收速率 |
ignore_client_bandwidth |
客户端声明了接收速率 | katana 应答 | katana 发送时使用 |
|---|---|---|---|
true(默认) |
任意 | auto |
congestion |
false |
是 | 以字节每秒表示的 down_mbps,或 0 |
Brutal,按客户端的速率,上限为 up_mbps |
false |
否 | 以字节每秒表示的 down_mbps,或 0 |
congestion |
congestion 默认是 cubic,也可以是 bbr 或 reno。客户端向 katana 发送时用什么方式,由 katana 的应答和客户端自己的设置决定。
預設值讓節點保持應答 auto 並使用 Cubic。Xboard 和 V2board 會發送 up_mbps 和 down_mbps,但不傳送 ignore_client_bandwidth,所以在你於 [node.hysteria] 中設定 ignore_client_bandwidth = false 或面板傳送 false 之前,節點一直應答 auto。helium 總是傳送這三個值:除非它寫明 false,ignore_client_bandwidth 都是 true,速率都是整數。Xboard 和 V2board 的數值可以是數字或數字字串,低於 1 Mbit/s 的值視為沒有設定。
面板速率的变化作用于变化之后建立的连接;已打开的连接保持它们商定的速率。Hysteria 2 用户的限速仍然叠加生效:katana 的每用户令牌桶(见 限速)无论商定了什么速率,都会限制用户的流量。
固定的连接上限
Section titled “固定的连接上限”以下上限适用于每个 Hysteria 2 节点,且无法修改:
| 上限 | 值 | 达到上限时 |
|---|---|---|
| 每节点 QUIC 连接数 | 262,144 | 新连接的握手被拒绝。 |
| 每节点活跃的代理流和 UDP 会话数 | 4,194,304 | 新的流被重置,新会话的数据包被丢弃。客户端的其他流不受影响。 |
| 每个 QUIC 连接的并发流数 | 65,536 | 客户端要等到有空闲的流,才能再打开新的流。 |
| 每个 QUIC 连接的 UDP 会话数 | 256 | 新会话的数据包被丢弃。 |
| QUIC 空闲超时 | 30 s | 连接在 30 秒内(如果客户端自己的空闲超时更短,则按客户端的)没有收到任何数据包时被关闭。客户端的 keep-alive 也算作数据包。 |
这些上限都不是按用户计算的。拒绝会以 debug 级别记录,例如 hysteria2: refusing a connection; the listener is full or stopping。
嗅探、路由与审计
Section titled “嗅探、路由与审计”Hysteria 2 的流與其他節點上的流走相同的路徑:准入、審計規則和路由,以及該使用者的限速。[node.controller].disable_sniffing = true 同樣會關閉 Hysteria 2 流的嗅探。Xboard 上本地描述的節點從不取得節點設定,所以沒有來自面板 routes 的審計規則;只有 rule_list_path 指定的檔案生效。helium 不下達路由,所以每個 helium 節點都是如此。
修改运行中节点的设置
Section titled “修改运行中节点的设置”| 修改 | 何时生效 |
|---|---|
| 面板的用户列表 | 下一次轮询时生效,无需重新绑定。其余用户保持连接;被移除用户的连接会结束。 |
面板的埠或混淆設定(port = 0,或 helium) |
下一次輪詢時生效,斷開該節點上的所有連線 |
| helium 的偽裝回應,或開啟、關閉其 UDP 中繼 | 下一次輪詢時生效,斷開該節點上的所有連線,這樣之前連上的客戶端不會繼續看到舊的回應或舊的 UDP 設定 |
面板的速率(port = 0,或 helium),或單獨修改 helium 的 UDP 空閒逾時 |
下一次輪詢時對新連線生效。已開啟的連線保持原來的速率和逾時。 |
檔案中 [node.hysteria] 下的任何鍵:port、credential、udp、udp_idle_timeout、obfs、obfs_password、偽裝回應、up_mbps、down_mbps、ignore_client_bandwidth 或 congestion |
立即生效,斷開該節點上的所有連線。節點會得到新的面板客戶端,重新讀取節點及其使用者:在 Xboard 和 V2board 上,客戶端用這個區塊補全面板的描述。設定或清除 port 會在本地描述和麵板描述之間切換。在 helium 上只能這樣修改 congestion;新增其他任何鍵都會使重載被拒絕。 |
文件中的 [node.controller].disable_sniffing 或 [node.controller.cert] |
立即生效,断开该节点上的所有连接 |
文件中的 [node.api].speed_limit |
立即生效,无需重新绑定。已打开的连接保持不变,并按新速率运行。 |
設定重載會在應用任何內容之前檢查 [node.hysteria] 下的取值。儲存了一個無法建立的修改(例如 udp_idle_timeout = 1)時,整次重載會被拒絕,記錄 reload: node <name>: udp_idle_timeout must be between 2 and 600 seconds; keeping current config,所有節點保持原樣執行。在 helium 節點上,congestion 以外的鍵也會以同樣的方式使重載被拒絕,訊息見面板描述的節點。儲存之前先執行 katana --test。
完整的重载过程见 热重载。
--test 和正在启动的节点报出的错误都带有节点前缀,例如 configuration error: node 1: …。
| 消息 | 原因 | 解决办法 |
|---|---|---|
hysteria2 node requires cert.mode = "file" |
没有配置证书,或设置了 ACME 模式。 | 设置 [node.controller.cert],包括 mode = "file"、cert_file 和 key_file。 |
No such file or directory (os error 2) |
证书或私钥路径不存在。 | 检查两个路径;使用绝对路径。 |
hysteria2: the certificate file contains no certificates |
cert_file 不是 PEM 证书。 |
让它指向 PEM 证书链,而不是 DER 文件或私钥。 |
hysteria2: the key file contains no private key |
key_file 中没有 PEM 私钥,例如它指向了证书。 |
让它指向 PEM 私钥。 |
hysteria2: certificate and key do not match: … |
key_file 属于另一张证书。 |
使用与这张证书一起签发的私钥。 |
obfs_password is set but obfs is not; did you mean obfs = "salamander"? |
设置了密码但没有设置类型,可能在本地,也可能来自关闭了混淆的 Xboard。 | 添加 obfs = "salamander",或删除密码。 |
unknown obfs "Salamander" (expected "salamander") |
拼写或大小写错误,或者 Xboard 节点仍是协议版本 1。 | 用小写写 salamander;把 Xboard 节点设为版本 2。 |
obfs_password must be at least 4 bytes for salamander |
密钥短于 4 字节或缺失。 | 使用较长的随机值,例如由 openssl rand -base64 24 生成。 |
udp_idle_timeout is set but udp is not enabled |
设置了 udp_idle_timeout 但没有 udp = true。 |
设置 udp = true,或删除该超时。 |
udp_idle_timeout must be between 2 and 600 seconds |
取值不在 2 到 600 之间。 |
选择范围内的值。 |
unknown hysteria credential kind "UUID" (expected "uuid" or "user_pass") |
取值不是可接受的字符串之一。它区分大小写。 | 使用 uuid 或 user_pass。 |
masquerade.status must not be 233, the Hysteria 2 authentication success status |
偽裝回應的狀態碼為 233。 |
使用其他狀態碼,例如 404。 |
masquerade.status is 1000, but must be 100 to 999 |
偽裝回應的狀態碼不在 100 到 999 之間。 |
使用真實的 HTTP 狀態碼。 |
unknown hysteria congestion "BBR" (expected "cubic", "bbr" or "reno") |
congestion 不是可接受的值之一。它區分大小寫。--test 對每個節點都檢查它,不只是 Hysteria 2 節點。 |
使用 cubic、bbr 或 reno。 |
[node.hysteria] udp is set, but a helium node's protocol is described by the panel; remove it (of [node.hysteria], only congestion is this host's to choose) |
helium 節點設定了 congestion 以外的 [node.hysteria] 鍵,或設定了 node_type;訊息會指明是哪個鍵。 |
刪除這個鍵,改在 helium 中設定它所表達的內容。 |
inbound <tag>: binding <address> failed: Address already in use (os error 98) |
其他进程或节点已占用 listen_ip 上的该 UDP 端口。 |
释放该端口或换一个端口。 |
在面板或監聽器階段失敗的啟動會被記錄並重試。node 1: node_info failed: …; retrying in <N>s 表示無法拉取或解析面板的節點設定,或 katana 拒絕了它,原因寫在 parse UniProxy config response: 之後;node 1: user_list failed: …; retrying in <N>s 表示使用者列表出現同樣的問題;node 1: initial start failed: …; retrying in <N>s 表示節點無法建立或繫結。第一次重試在 1 秒後進行,之後每次失敗等待時間翻倍,最長 60 秒;如果 update_periodic 更短,則最長為 update_periodic。每次嘗試都會重新向面板請求使用者列表,對於面板描述的節點,還會重新請求節點設定。儲存對該節點 [[node]] 條目的修改會立即觸發重試,所以你可以直接在檔案中排除原因,無需重啟 katana。之後無法套用的變更(例如面板下達了 katana 拒絕的混淆設定)會被記錄,這個例子記錄為 node 1: node_info: parse UniProxy config response: …,katana 保留上一次的設定,並在下一次輪詢時重試。
客户端一侧:
| 客户端现象 | 原因 |
|---|---|
authentication error, HTTP status code: 404(或你设置的伪装状态码) |
认证字符串与 credential 模式不匹配,或者该用户不在面板为此节点下发的列表中。 |
| 超时,没有认证错误 | 混淆设置或密码与节点不一致、UDP 端口被阻断,或者节点没有在监听。 |
x509: certificate relies on legacy Common Name field, use SANs instead |
证书没有 subjectAltName。 |