Skip to content

Commit 34c90e6

Browse files
committed
Add hysteria2 realm service and support
1 parent 18f1056 commit 34c90e6

20 files changed

Lines changed: 1167 additions & 33 deletions

File tree

constant/proxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
TypeCCM = "ccm"
3333
TypeOCM = "ocm"
3434
TypeOOMKiller = "oom-killer"
35+
TypeHysteriaRealm = "hysteria-realm"
3536
TypeACME = "acme"
3637
TypeCloudflareOriginCA = "cloudflare-origin-ca"
3738
)

docs/configuration/inbound/hysteria2.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ icon: material/alert-decagram
44

55
!!! quote "Changes in sing-box 1.14.0"
66

7-
:material-plus: [bbr_profile](#bbr_profile)
7+
:material-plus: [bbr_profile](#bbr_profile)
8+
:material-plus: [realm](#realm)
89

910
!!! quote "Changes in sing-box 1.11.0"
1011

@@ -39,7 +40,14 @@ icon: material/alert-decagram
3940

4041
"masquerade": "", // or {}
4142
"bbr_profile": "",
42-
"brutal_debug": false
43+
"brutal_debug": false,
44+
"realm": {
45+
"server_url": "https://realm.example.com",
46+
"token": "",
47+
"realm_id": "",
48+
"stun_servers": [],
49+
"http_client": {}
50+
}
4351
}
4452
```
4553

@@ -164,3 +172,47 @@ BBR congestion control algorithm profile, one of `conservative` `standard` `aggr
164172
#### brutal_debug
165173

166174
Enable debug information logging for Hysteria Brutal CC.
175+
176+
#### realm
177+
178+
!!! question "Since sing-box 1.14.0"
179+
180+
Register this inbound to a Hysteria Realm rendezvous service to enable NAT traversal.
181+
182+
The inbound discovers its public addresses via STUN, registers them on the realm, and uses UDP hole-punching to accept incoming clients without a publicly reachable listen address.
183+
184+
See [Hysteria Realm](/configuration/service/hysteria-realm/) for the rendezvous service.
185+
186+
#### realm.server_url
187+
188+
==Required==
189+
190+
Realm rendezvous service URL.
191+
192+
#### realm.token
193+
194+
Bearer token for the realm. Must match one of `users[].token` configured on the realm.
195+
196+
#### realm.realm_id
197+
198+
==Required==
199+
200+
Slot identifier on the realm.
201+
202+
1–64 characters, must match `^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$`.
203+
204+
Outbounds must use the same `realm_id` to find this server.
205+
206+
#### realm.stun_servers
207+
208+
==Required==
209+
210+
List of STUN servers (`host` or `host:port`) used to discover public addresses.
211+
212+
Port defaults to `3478`.
213+
214+
#### realm.http_client
215+
216+
HTTP client used to talk to the realm.
217+
218+
See [HTTP Client](/configuration/shared/http-client/) for details.

docs/configuration/inbound/hysteria2.zh.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ icon: material/alert-decagram
44

55
!!! quote "sing-box 1.14.0 中的更改"
66

7-
:material-plus: [bbr_profile](#bbr_profile)
7+
:material-plus: [bbr_profile](#bbr_profile)
8+
:material-plus: [realm](#realm)
89

910
!!! quote "sing-box 1.11.0 中的更改"
1011

@@ -39,7 +40,14 @@ icon: material/alert-decagram
3940

4041
"masquerade": "", // 或 {}
4142
"bbr_profile": "",
42-
"brutal_debug": false
43+
"brutal_debug": false,
44+
"realm": {
45+
"server_url": "https://realm.example.com",
46+
"token": "",
47+
"realm_id": "",
48+
"stun_servers": [],
49+
"http_client": {}
50+
}
4351
}
4452
```
4553

@@ -161,3 +169,47 @@ BBR 拥塞控制算法配置,可选 `conservative` `standard` `aggressive`。
161169
#### brutal_debug
162170

163171
启用 Hysteria Brutal CC 的调试信息日志记录。
172+
173+
#### realm
174+
175+
!!! question "自 sing-box 1.14.0 起"
176+
177+
将此入站注册到 Hysteria Realm 会合服务,以启用 NAT 穿透。
178+
179+
入站通过 STUN 发现自己的公网地址并注册到 realm,借助 UDP 打洞接受客户端连接,无需可公网直达的监听地址。
180+
181+
会合服务参阅 [Hysteria Realm](/zh/configuration/service/hysteria-realm/)
182+
183+
#### realm.server_url
184+
185+
==必填==
186+
187+
Realm 会合服务 URL。
188+
189+
#### realm.token
190+
191+
Realm 的 Bearer 令牌,需与 realm 上配置的 `users[].token` 之一匹配。
192+
193+
#### realm.realm_id
194+
195+
==必填==
196+
197+
Realm 上的槽位标识符。
198+
199+
1–64 字符,需匹配 `^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$`
200+
201+
出站需使用相同的 `realm_id` 才能找到本服务器。
202+
203+
#### realm.stun_servers
204+
205+
==必填==
206+
207+
用于发现公网地址的 STUN 服务器列表(`host``host:port`)。
208+
209+
端口默认为 `3478`
210+
211+
#### realm.http_client
212+
213+
与 realm 通信使用的 HTTP 客户端。
214+
215+
参阅 [HTTP 客户端](/zh/configuration/shared/http-client/) 了解详情。

docs/configuration/outbound/hysteria2.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
!!! quote "Changes in sing-box 1.14.0"
22

33
:material-plus: [hop_interval_max](#hop_interval_max)
4-
:material-plus: [bbr_profile](#bbr_profile)
4+
:material-plus: [bbr_profile](#bbr_profile)
5+
:material-plus: [realm](#realm)
56

67
!!! quote "Changes in sing-box 1.11.0"
78

@@ -36,6 +37,13 @@
3637

3738
"bbr_profile": "",
3839
"brutal_debug": false,
40+
"realm": {
41+
"server_url": "https://realm.example.com",
42+
"token": "",
43+
"realm_id": "",
44+
"stun_servers": [],
45+
"http_client": {}
46+
},
3947

4048
... // Dial Fields
4149
}
@@ -61,6 +69,8 @@
6169

6270
The server address.
6371

72+
Conflicts with `realm`.
73+
6474
#### server_port
6575

6676
==Required==
@@ -69,13 +79,15 @@ The server port.
6979

7080
Ignored if `server_ports` is set.
7181

82+
Conflicts with `realm`.
83+
7284
#### server_ports
7385

7486
!!! question "Since sing-box 1.11.0"
7587

7688
Server port range list.
7789

78-
Conflicts with `server_port`.
90+
Conflicts with `server_port` and `realm`.
7991

8092
#### hop_interval
8193

@@ -143,6 +155,50 @@ BBR congestion control algorithm profile, one of `conservative` `standard` `aggr
143155

144156
Enable debug information logging for Hysteria Brutal CC.
145157

158+
#### realm
159+
160+
!!! question "Since sing-box 1.14.0"
161+
162+
Connect to a Hysteria2 server through a Hysteria Realm rendezvous service.
163+
164+
The outbound queries the realm for the server's current public addresses, performs UDP hole-punching, and proceeds with the normal QUIC handshake.
165+
166+
Conflicts with `server`, `server_port` and `server_ports`.
167+
168+
The TLS SNI defaults to the host portion of `server_url`. Set `tls.server_name` to match the certificate the Hysteria2 server presents.
169+
170+
See [Hysteria Realm](/configuration/service/hysteria-realm/) for the rendezvous service.
171+
172+
#### realm.server_url
173+
174+
==Required==
175+
176+
Realm rendezvous service URL.
177+
178+
#### realm.token
179+
180+
Bearer token for the realm. Must match one of `users[].token` configured on the realm.
181+
182+
#### realm.realm_id
183+
184+
==Required==
185+
186+
The same slot identifier the target Hysteria2 server registered.
187+
188+
#### realm.stun_servers
189+
190+
==Required==
191+
192+
List of STUN servers (`host` or `host:port`) used to discover this client's public addresses.
193+
194+
Port defaults to `3478`.
195+
196+
#### realm.http_client
197+
198+
HTTP client used to talk to the realm.
199+
200+
See [HTTP Client](/configuration/shared/http-client/) for details.
201+
146202
### Dial Fields
147203

148204
See [Dial Fields](/configuration/shared/dial/) for details.

docs/configuration/outbound/hysteria2.zh.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
!!! quote "sing-box 1.14.0 中的更改"
22

33
:material-plus: [hop_interval_max](#hop_interval_max)
4-
:material-plus: [bbr_profile](#bbr_profile)
4+
:material-plus: [bbr_profile](#bbr_profile)
5+
:material-plus: [realm](#realm)
56

67
!!! quote "sing-box 1.11.0 中的更改"
78

@@ -36,6 +37,13 @@
3637

3738
"bbr_profile": "",
3839
"brutal_debug": false,
40+
"realm": {
41+
"server_url": "https://realm.example.com",
42+
"token": "",
43+
"realm_id": "",
44+
"stun_servers": [],
45+
"http_client": {}
46+
},
3947

4048
... // 拨号字段
4149
}
@@ -59,6 +67,8 @@
5967

6068
服务器地址。
6169

70+
`realm` 冲突。
71+
6272
#### server_port
6373

6474
==必填==
@@ -67,13 +77,15 @@
6777

6878
如果设置了 `server_ports`,则忽略此项。
6979

80+
`realm` 冲突。
81+
7082
#### server_ports
7183

7284
!!! question "自 sing-box 1.11.0 起"
7385

7486
服务器端口范围列表。
7587

76-
`server_port` 冲突。
88+
`server_port` `realm` 冲突。
7789

7890
#### hop_interval
7991

@@ -141,6 +153,50 @@ BBR 拥塞控制算法配置,可选 `conservative` `standard` `aggressive`。
141153

142154
启用 Hysteria Brutal CC 的调试信息日志记录。
143155

156+
#### realm
157+
158+
!!! question "自 sing-box 1.14.0 起"
159+
160+
通过 Hysteria Realm 会合服务连接 Hysteria2 服务器。
161+
162+
出站从 realm 查询服务器当前的公网地址,执行 UDP 打洞,然后进行常规的 QUIC 握手。
163+
164+
`server``server_port``server_ports` 冲突。
165+
166+
TLS SNI 默认使用 `server_url` 中的主机名。需设置 `tls.server_name` 以匹配 Hysteria2 服务器证书覆盖的名字。
167+
168+
会合服务参阅 [Hysteria Realm](/zh/configuration/service/hysteria-realm/)
169+
170+
#### realm.server_url
171+
172+
==必填==
173+
174+
Realm 会合服务 URL。
175+
176+
#### realm.token
177+
178+
Realm 的 Bearer 令牌,需与 realm 上配置的 `users[].token` 之一匹配。
179+
180+
#### realm.realm_id
181+
182+
==必填==
183+
184+
目标 Hysteria2 服务器注册时使用的相同槽位标识符。
185+
186+
#### realm.stun_servers
187+
188+
==必填==
189+
190+
用于发现本客户端公网地址的 STUN 服务器列表(`host``host:port`)。
191+
192+
端口默认为 `3478`
193+
194+
#### realm.http_client
195+
196+
与 realm 通信使用的 HTTP 客户端。
197+
198+
参阅 [HTTP 客户端](/zh/configuration/shared/http-client/) 了解详情。
199+
144200
### 拨号字段
145201

146202
参阅 [拨号字段](/zh/configuration/shared/dial/)

0 commit comments

Comments
 (0)