English
hysteria2
Hysteria 2 over QUIC: the client authenticates with a single HTTP/3 request, then each TCP connection is a QUIC stream and UDP goes as QUIC datagrams. The sides negotiate the speed: with known bandwidths Brutal congestion control works, otherwise BBR. The server answers foreign HTTP/3 requests with a masquerade. Compatible with sing-box hysteria2 and the official Hysteria 2.
TLS (the tls block) is required on both sides, the ALPN is h3. The shared QUIC fields are in quic.md.
Inbound
| Field | Type | Default | Meaning |
|---|---|---|---|
users | list of {name, password} | — | The users' passwords |
up_mbps, down_mbps | number | 0 | The server's speed to and from the client, Mbit/s; 0 means no limit (BBR) |
ignore_client_bandwidth | bool | false | Ignore the speed the client declares |
obfs | block {salamander: {password}} or {gecko: {…}} | — | Packet obfuscation, see below; the kind is the key, a type field is an error |
masquerade | block or string | a 404 answer | What to answer to foreign HTTP/3 requests |
bbr_profile | standard, conservative, aggressive | standard | BBR tuning while the speed is not negotiated, see below |
brutal_debug | bool | false | Write the share of acknowledged Brutal packets to the log (debug level) |
Socket settings are the listener block (the server listens on UDP).
masquerade is one of three:
yaml
# a fixed answer
masquerade:
type: string
status_code: 200 # 200 by default
headers:
content-type: text/html
content: "<html>hello</html>"
# the files of a directory, like Go's http.FileServer
masquerade:
type: file
directory: /var/www # $VAR is expanded; a directory that does not exist gives 404 answers
# a reverse proxy to a site
masquerade:
type: proxy
url: https://www.example.com/
rewrite_host: false # true sends the site's Host instead of the one the client sentA URL string is the short form: masquerade: file:///var/www is type: file, masquerade: https://… is type: proxy.
type: file serves a file, the index.html of a directory or a directory listing; a directory without a trailing / and …/index.html are redirected (301). Last-Modified, If-Modified-Since and a single Range are supported; several ranges give the whole file. The content type comes from the extension (Go's built-in table) or the first bytes.
type: proxy goes to the site directly, bypassing routing, over HTTP/1.1, trusting the system root certificates. The client's path and query are appended to url; connection headers and X-Forwarded-* are dropped. The request body is up to 1 MiB. If the site is unavailable, 502.
Outbound
| Field | Type | Default | Meaning |
|---|---|---|---|
server | host:port | required | The server address; the port can be omitted with hop |
hop | block | — | Port hopping: ports — a list of "port" or "start:end"; interval — how often to change the port, 30s by default, no less than 5s; interval_max — the upper bound of a random interval, interval by default. The sing-box names (server_ports, hop_interval) are an error with a hint |
password | string | required | The password |
up_mbps, down_mbps | number | 0 | The client's speed; 0 means BBR |
obfs | block {salamander: {password}} or {gecko: {…}} | — | Obfuscation, as on the server |
network | tcp, udp or a list | both | What to pass |
bbr_profile | standard, conservative, aggressive | standard | As on the server |
brutal_debug | bool | false | As on the server |
disable_chrome_parrot | bool | false | true gives an ordinary QUIC handshake (rustls) instead of a Chrome-like one |
A Chrome-like handshake
By default the client imitates Chrome's QUIC handshake, as sing-box does with ChromeParrot. This overrides the windows, stream limits, idle timeout and initial_packet_size from quic, and the versions, ciphers and groups from tls; alpn, sni, disable_sni, certificate verification and the client certificate still apply. There is no session resumption or 0-RTT. disable_chrome_parrot: true turns this off.
Obfuscation
salamander: {password} — each packet is XORed with a key derived from the password and a random salt.
gecko: {password, min_packet_size, max_packet_size} — Salamander, and in addition the handshake packets (QUIC long header) are cut into 2–8 pieces, each padded with random bytes to a random size from [min_packet_size, max_packet_size] and sent as a separate datagram. The defaults are 512 and 1200; 0 < min ≤ max ≤ 2048 is allowed. The sizes may differ between the sides: the receiver neither knows nor checks them. The password is the same on both sides.
yaml
obfs:
gecko:
password: obfs-secret
min_packet_size: 600
max_packet_size: 1100Congestion control
Until the sides agree on a speed (or if one of them has not set up_mbps/down_mbps), BBR works. bbr_profile changes its gains and the length of the startup the same way as the reference implementation's profiles:
| Profile | Startup gain | Window during startup | Window afterwards | Rounds without growth before startup ends |
|---|---|---|---|---|
standard | 2.885 | 2.885 | 2.0 | 3 |
conservative | 2.25 | 1.75 | 1.75 | 2 |
aggressive | 3.0 | 2.25 | 2.5 | 4 |
After the speed is negotiated, Brutal works; brutal_debug: true writes … [brutal] ACK rate: … lines every two seconds at the debug level, as the reference does.
Not supported
realm(on both sides) —realm: not implemented.
Example
yaml
inbounds:
hy2-in:
hysteria2:
listen: ":443"
up_mbps: 500
down_mbps: 500
users:
- name: alice
password: secret
obfs:
salamander:
password: obfs-secret
masquerade:
type: file
directory: /var/www
tls:
certificate_path: /etc/ours/cert.pem
key_path: /etc/ours/key.pem
outbounds:
hy2-out:
hysteria2:
server: hy.example.com:443
hop:
ports: ["20000:20100"]
interval: 30s
password: secret
up_mbps: 50
down_mbps: 200
obfs:
salamander:
password: obfs-secret
tls:
sni: hy.example.com
route:
final:
outbound: hy2-outModule description for developers: modules/hysteria2.