-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73af2f8
commit a7b5aa1
Showing
7 changed files
with
268 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Hysteria2 | ||
|
||
- 名称:`hysteria2` | ||
- 类型:入站 / 出站 | ||
|
||
## InboundConfigurationObject | ||
|
||
无需配置 | ||
|
||
## OutboundConfigurationObject | ||
|
||
```json | ||
{ | ||
"servers": [ | ||
{ | ||
"address": "127.0.0.1", | ||
"port": 1234 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### ServerObject | ||
|
||
```json | ||
{ | ||
"address": "127.0.0.1", | ||
"port": 1234 | ||
} | ||
``` | ||
|
||
> `address`: address | ||
服务器地址,支持 IPv4、IPv6 和域名。必填。 | ||
|
||
> `port`: number | ||
服务器端口,必填。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Hysteria2 | ||
|
||
魔改 quic-go 拥塞控制的代理协议。 | ||
|
||
1. 得益于 QUIC 的全加密和填充,大大地增加中间防火墙嗅探的负担 | ||
2. 强制要求使用 TLS 1.3 | ||
3. 真正的多路复用,还从根本上解决了 TLS 和多路复用带来的队头阻塞问题 | ||
|
||
## 协议修改说明 | ||
|
||
- 在 V2ray 中,Hysteria2 TCP 被分成了两个部分: | ||
|
||
1. `TLS + HTTP3` 传输层;包含认证、协商、拥塞控制等 | ||
2. `Proxy Header` 代理层;包含解析目标地址、Padding 等 | ||
|
||
Hysteria2 可以作为传输层与 Vmess、Shadowsocks、Trojan 搭配使用,也可以兼用官方版。若把 Hysteria2 作为传输层,只能使用其 Stream,也就是说传输 UDP 时就是 UDP Over Stream。 | ||
|
||
- Padding 目前为固定长度和内容,不影响实际使用和兼容性 | ||
|
||
## Hysteria2Object | ||
|
||
`Hysteria2Object` 对应传输配置的 `hysteria2Settings` 项。 | ||
|
||
```json | ||
{ | ||
"password": "password", | ||
"use_udp_extension": true, | ||
"congestion": { | ||
"type": "bbr", | ||
"up_mbps": 50, | ||
"down_mbps": 100 | ||
} | ||
} | ||
``` | ||
|
||
> `password`: string | ||
认证密码,留空为不认证 | ||
|
||
> `use_udp_extension`: bool | ||
是否启用 UDP,默认不启用 | ||
|
||
> `congestion`: [CongestionObject](#CongestionObject) | ||
拥塞算法配置 | ||
|
||
## CongestionObject | ||
|
||
用于控制本地网络的发包速度。理论上能够充分利用网络带宽,做到效益最大化,即为最佳拥塞算法。不同的拥塞算法会影响 Hysteria2 的性能表现。 | ||
|
||
```json | ||
{ | ||
"type": "bbr", | ||
"up_mbps": 50, | ||
"down_mbps": 100 | ||
} | ||
``` | ||
|
||
> `type`: string | ||
可选: | ||
|
||
- `bbr` 被广泛使用的,推荐在移动网络环境下使用(默认) | ||
- `brutal` 需要正确地设置好本机实际带宽才能生效,推荐在带宽稳定的环境下使用 | ||
|
||
> `up_mbps`: int | ||
本机的上传速度,单位 Mbit/s | ||
|
||
选择 `brutal` 时,必填;留空或 0 时转换成 `bbr` | ||
|
||
> `down_mbps`: int | ||
本机的下传速度,单位 Mbit/s | ||
|
||
选择 `brutal` 时,必填;留空或 0 时转换成 `bbr` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Hysteria2 | ||
|
||
## Hysteria2 入站 | ||
|
||
inbound.hysteria2 | ||
|
||
无需配置 | ||
|
||
## Hysteria2 出站 | ||
|
||
outbound.hysteria2 | ||
|
||
```json | ||
{ | ||
"server": [ | ||
{ | ||
"address": "127.0.0.1", | ||
"port": 1234 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
> `address`: string | ||
服务器地址,支持 IP 地址或者域名。 | ||
|
||
> `port`: number | ||
服务器端口号。 | ||
|
||
## Hysteria2 兼容 | ||
|
||
若要使用与[官方版](https://hysteria.network/)完全兼容的 Hysteria2,请把传输层也设置成 Hysteria2,并设置密码 | ||
|
||
:::tip | ||
|
||
- 配置 TLS 时,可以使用 allowInsecure 和系统根证书,暂不支持自签证书和 PinnedPeerCertificateChainSha256 | ||
|
||
- 若不配置 TLS,则默认使用 allowInsecure | ||
|
||
::: | ||
|
||
## 最佳实践 | ||
|
||
- 无需 UDP | ||
|
||
如果你不需要代理 UDP,那么 `vmess + hysteria2`、`trojan + hysteria2`、`hysteria2 + hysteria2` (代理层+ 传输层)三者的效果是一样的。 `trojan + hysteria2` 的性能可能会更佳。 | ||
|
||
- 需 UDP(透明代理、socks5 等) | ||
|
||
如果你选择搭配 `vmess + hysteria2`、`trojan + hysteria2`,那么就是 UDP over stream。参考 TUIC 的 `quic` udp 模式。 | ||
|
||
代理 TCP 时,效果都是一致的。 | ||
|
||
- 无需再使用 grpc、h2、smux 等多路复用 | ||
|
||
QUIC 彻头彻尾地解决了多路复用带来的各种小问题,其本身就自带多路复用,无需再多此一举。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Hysteria2 | ||
|
||
魔改 [quic-go](https://github.com/quic-go/quic-go) 拥塞控制的代理协议。 | ||
|
||
1. 得益于 QUIC 的全加密和填充,大大地增加中间防火墙嗅探的负担 | ||
2. 强制要求使用 TLS 1.3 | ||
3. 真正的多路复用,还从根本上解决了 TLS 和多路复用带来的队头阻塞问题 | ||
|
||
## 协议修改说明 | ||
|
||
- 在 V2ray 中,Hysteria2 TCP 被分成了两个部分: | ||
|
||
1. `TLS + HTTP3` 传输层;包含认证、协商、拥塞控制等 | ||
2. `Proxy Header` 代理层;包含解析目标地址、Padding 等 | ||
|
||
Hysteria2 可以作为传输层与 Vmess、Shadowsocks、Trojan 搭配使用,也可以兼用官方版。若把 Hysteria2 作为传输层,只能使用其 Stream,也就是说传输 UDP 时就是 UDP Over Stream。 | ||
|
||
- Padding 目前为固定长度和内容,不影响实际使用和兼容性 | ||
|
||
<!-- 3. 协商时增加了选择 UDP 模式 --> | ||
|
||
<!-- ``` --> | ||
<!-- :status: 233 HyOK --> | ||
<!-- Hysteria-UDP: [true/false] --> | ||
<!-- Hysteria-UDP-Mode: [string] // 新增 --> | ||
<!-- Hysteria-CC-RX: [uint/"auto"] --> | ||
<!-- Hysteria-Padding: [string] --> | ||
<!-- ``` --> | ||
|
||
## Hysteria2 Stream | ||
|
||
stream.hysteria | ||
|
||
> `password`: string | ||
认证密码,留空为不认证 | ||
|
||
> `use_udp_extension`: bool | ||
是否启用 UDP,默认不启用 | ||
|
||
使用 QUIC 的 udp extension 功能,解决代理基于 UDP 的可靠传输层协议时会导致队头阻塞;仅 hysteria2 代理协议可用,其他协议不支持。不代理 UDP 时,无需启用。 | ||
|
||
<!-- > `udp_mode`: string --> | ||
|
||
<!-- 需要 Server 也同时开启 UDP 功能。 --> | ||
|
||
<!-- 可选: --> | ||
|
||
<!-- - `uou` UDP over UDP; 使用 QUIC 的 UDP Extension 功能,具有原生 UDP 的全部特点,需要分片,并数据被加密保护 (默认) --> | ||
<!-- - `uos` UDP over Stream; 每一个 UDP 都会安排在一条 Stream 上 --> | ||
|
||
<!-- 若 Server 不支持 `uos` 时,回退使用`uou`。 --> | ||
|
||
> `congestion`: [CongestionObject](#CongestionObject) | ||
拥塞算法配置 | ||
|
||
## CongestionObject | ||
|
||
stream.hysteria2.congestion | ||
|
||
用于控制本地网络的发包速度。理论上能够充分利用网络带宽,做到效益最大化,即为最佳拥塞算法。不同的拥塞算法会影响 Hysteria2 的性能表现。 | ||
|
||
> `type`: string | ||
可选: | ||
|
||
- `bbr` 被广泛使用的,推荐在移动网络环境下使用(默认) | ||
- `brutal` 需要正确地设置好本机实际带宽才能生效,推荐在带宽稳定的环境下使用 | ||
|
||
> `up_mbps`: int | ||
本机的上传速度,单位 Mbit/s | ||
|
||
选择 `brutal` 时,必填;留空或 0 时转换成 `bbr` | ||
|
||
> `down_mbps`: int | ||
本机的下传速度,单位 Mbit/s | ||
|
||
选择 `brutal` 时,必填;留空或 0 时转换成 `bbr` |