mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-01-10 10:00:01 +00:00
Add port hopping for hysteria2
This commit is contained in:
parent
6f73096972
commit
24a57b5270
|
@ -5,6 +5,7 @@ icon: material/alert-decagram
|
||||||
!!! quote "Changes in sing-box 1.11.0"
|
!!! quote "Changes in sing-box 1.11.0"
|
||||||
|
|
||||||
:material-alert: [masquerade](#masquerade)
|
:material-alert: [masquerade](#masquerade)
|
||||||
|
:material-alert: [ignore_client_bandwidth](#ignore_client_bandwidth)
|
||||||
|
|
||||||
### Structure
|
### Structure
|
||||||
|
|
||||||
|
@ -75,9 +76,13 @@ Authentication password
|
||||||
|
|
||||||
#### ignore_client_bandwidth
|
#### ignore_client_bandwidth
|
||||||
|
|
||||||
Commands the client to use the BBR flow control algorithm instead of Hysteria CC.
|
*When `up_mbps` and `down_mbps` are not set*:
|
||||||
|
|
||||||
Conflict with `up_mbps` and `down_mbps`.
|
Commands clients to use the BBR CC instead of Hysteria CC.
|
||||||
|
|
||||||
|
*When `up_mbps` and `down_mbps` are set*:
|
||||||
|
|
||||||
|
Deny clients to use the BBR CC.
|
||||||
|
|
||||||
#### tls
|
#### tls
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ icon: material/alert-decagram
|
||||||
!!! quote "sing-box 1.11.0 中的更改"
|
!!! quote "sing-box 1.11.0 中的更改"
|
||||||
|
|
||||||
:material-alert: [masquerade](#masquerade)
|
:material-alert: [masquerade](#masquerade)
|
||||||
|
:material-alert: [ignore_client_bandwidth](#ignore_client_bandwidth)
|
||||||
|
|
||||||
### 结构
|
### 结构
|
||||||
|
|
||||||
|
@ -72,9 +73,13 @@ Hysteria 用户
|
||||||
|
|
||||||
#### ignore_client_bandwidth
|
#### ignore_client_bandwidth
|
||||||
|
|
||||||
|
*当 `up_mbps` 和 `down_mbps` 未设定时*:
|
||||||
|
|
||||||
命令客户端使用 BBR 拥塞控制算法而不是 Hysteria CC。
|
命令客户端使用 BBR 拥塞控制算法而不是 Hysteria CC。
|
||||||
|
|
||||||
与 `up_mbps` 和 `down_mbps` 冲突。
|
*当 `up_mbps` 和 `down_mbps` 已设定时*:
|
||||||
|
|
||||||
|
禁止客户端使用 BBR 拥塞控制算法。
|
||||||
|
|
||||||
#### tls
|
#### tls
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
---
|
||||||
|
icon: material/new-box
|
||||||
|
---
|
||||||
|
|
||||||
|
!!! quote "Changes in sing-box 1.11.0"
|
||||||
|
|
||||||
|
:material-plus: [server_ports](#server_ports)
|
||||||
|
:material-plus: [hop_interval](#hop_interval)
|
||||||
|
|
||||||
### Structure
|
### Structure
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
@ -7,6 +16,10 @@
|
||||||
|
|
||||||
"server": "127.0.0.1",
|
"server": "127.0.0.1",
|
||||||
"server_port": 1080,
|
"server_port": 1080,
|
||||||
|
"server_ports": [
|
||||||
|
"2080:3000"
|
||||||
|
],
|
||||||
|
"hop_interval": "",
|
||||||
"up_mbps": 100,
|
"up_mbps": 100,
|
||||||
"down_mbps": 100,
|
"down_mbps": 100,
|
||||||
"obfs": {
|
"obfs": {
|
||||||
|
@ -22,6 +35,10 @@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!! note ""
|
||||||
|
|
||||||
|
You can ignore the JSON Array [] tag when the content is only one item
|
||||||
|
|
||||||
!!! warning "Difference from official Hysteria2"
|
!!! warning "Difference from official Hysteria2"
|
||||||
|
|
||||||
The official Hysteria2 supports an authentication method called **userpass**,
|
The official Hysteria2 supports an authentication method called **userpass**,
|
||||||
|
@ -44,6 +61,24 @@ The server address.
|
||||||
|
|
||||||
The server port.
|
The server port.
|
||||||
|
|
||||||
|
Ignored if `server_ports` is set.
|
||||||
|
|
||||||
|
#### server_ports
|
||||||
|
|
||||||
|
!!! question "Since sing-box 1.11.0"
|
||||||
|
|
||||||
|
Server port range list.
|
||||||
|
|
||||||
|
Conflicts with `server_port`.
|
||||||
|
|
||||||
|
#### hop_interval
|
||||||
|
|
||||||
|
!!! question "Since sing-box 1.11.0"
|
||||||
|
|
||||||
|
Port hopping interval.
|
||||||
|
|
||||||
|
`30s` is used by default.
|
||||||
|
|
||||||
#### up_mbps, down_mbps
|
#### up_mbps, down_mbps
|
||||||
|
|
||||||
Max bandwidth, in Mbps.
|
Max bandwidth, in Mbps.
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
---
|
||||||
|
icon: material/new-box
|
||||||
|
---
|
||||||
|
|
||||||
|
!!! quote "sing-box 1.11.0 中的更改"
|
||||||
|
|
||||||
|
:material-plus: [server_ports](#server_ports)
|
||||||
|
:material-plus: [hop_interval](#hop_interval)
|
||||||
|
|
||||||
### 结构
|
### 结构
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
@ -7,6 +16,10 @@
|
||||||
|
|
||||||
"server": "127.0.0.1",
|
"server": "127.0.0.1",
|
||||||
"server_port": 1080,
|
"server_port": 1080,
|
||||||
|
"server_ports": [
|
||||||
|
"2080:3000"
|
||||||
|
],
|
||||||
|
"hop_interval": "",
|
||||||
"up_mbps": 100,
|
"up_mbps": 100,
|
||||||
"down_mbps": 100,
|
"down_mbps": 100,
|
||||||
"obfs": {
|
"obfs": {
|
||||||
|
@ -22,6 +35,10 @@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
!!! note ""
|
||||||
|
|
||||||
|
当内容只有一项时,可以忽略 JSON 数组 [] 标签
|
||||||
|
|
||||||
!!! warning "与官方 Hysteria2 的区别"
|
!!! warning "与官方 Hysteria2 的区别"
|
||||||
|
|
||||||
官方程序支持一种名为 **userpass** 的验证方式,
|
官方程序支持一种名为 **userpass** 的验证方式,
|
||||||
|
@ -42,6 +59,24 @@
|
||||||
|
|
||||||
服务器端口。
|
服务器端口。
|
||||||
|
|
||||||
|
如果设置了 `server_ports`,则忽略此项。
|
||||||
|
|
||||||
|
#### server_ports
|
||||||
|
|
||||||
|
!!! question "自 sing-box 1.11.0 起"
|
||||||
|
|
||||||
|
服务器端口范围列表。
|
||||||
|
|
||||||
|
与 `server_port` 冲突。
|
||||||
|
|
||||||
|
#### hop_interval
|
||||||
|
|
||||||
|
!!! question "自 sing-box 1.11.0 起"
|
||||||
|
|
||||||
|
端口跳跃间隔。
|
||||||
|
|
||||||
|
默认使用 `30s`。
|
||||||
|
|
||||||
#### up_mbps, down_mbps
|
#### up_mbps, down_mbps
|
||||||
|
|
||||||
最大带宽。
|
最大带宽。
|
||||||
|
|
|
@ -112,11 +112,13 @@ type Hysteria2MasqueradeString struct {
|
||||||
type Hysteria2OutboundOptions struct {
|
type Hysteria2OutboundOptions struct {
|
||||||
DialerOptions
|
DialerOptions
|
||||||
ServerOptions
|
ServerOptions
|
||||||
UpMbps int `json:"up_mbps,omitempty"`
|
ServerPorts badoption.Listable[string] `json:"server_ports,omitempty"`
|
||||||
DownMbps int `json:"down_mbps,omitempty"`
|
HopInterval badoption.Duration `json:"hop_interval,omitempty"`
|
||||||
Obfs *Hysteria2Obfs `json:"obfs,omitempty"`
|
UpMbps int `json:"up_mbps,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
DownMbps int `json:"down_mbps,omitempty"`
|
||||||
Network NetworkList `json:"network,omitempty"`
|
Obfs *Hysteria2Obfs `json:"obfs,omitempty"`
|
||||||
|
Password string `json:"password,omitempty"`
|
||||||
|
Network NetworkList `json:"network,omitempty"`
|
||||||
OutboundTLSOptionsContainer
|
OutboundTLSOptionsContainer
|
||||||
BrutalDebug bool `json:"brutal_debug,omitempty"`
|
BrutalDebug bool `json:"brutal_debug,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/sagernet/sing-box/adapter"
|
"github.com/sagernet/sing-box/adapter"
|
||||||
"github.com/sagernet/sing-box/adapter/outbound"
|
"github.com/sagernet/sing-box/adapter/outbound"
|
||||||
|
@ -70,6 +71,8 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
BrutalDebug: options.BrutalDebug,
|
BrutalDebug: options.BrutalDebug,
|
||||||
ServerAddress: options.ServerOptions.Build(),
|
ServerAddress: options.ServerOptions.Build(),
|
||||||
|
ServerPorts: options.ServerPorts,
|
||||||
|
HopInterval: time.Duration(options.HopInterval),
|
||||||
SendBPS: uint64(options.UpMbps * hysteria.MbpsToBps),
|
SendBPS: uint64(options.UpMbps * hysteria.MbpsToBps),
|
||||||
ReceiveBPS: uint64(options.DownMbps * hysteria.MbpsToBps),
|
ReceiveBPS: uint64(options.DownMbps * hysteria.MbpsToBps),
|
||||||
SalamanderPassword: salamanderPassword,
|
SalamanderPassword: salamanderPassword,
|
||||||
|
|
Loading…
Reference in a new issue