mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-08 03:34:13 +08:00
Add back port hopping to hysteria 1
This commit is contained in:
parent
efc5c542fb
commit
6e91de51f1
@ -1,3 +1,12 @@
|
|||||||
|
---
|
||||||
|
icon: material/new-box
|
||||||
|
---
|
||||||
|
|
||||||
|
!!! quote "Changes in sing-box 1.12.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": "100 Mbps",
|
"up": "100 Mbps",
|
||||||
"up_mbps": 100,
|
"up_mbps": 100,
|
||||||
"down": "100 Mbps",
|
"down": "100 Mbps",
|
||||||
@ -38,6 +51,22 @@ The server address.
|
|||||||
|
|
||||||
The server port.
|
The server port.
|
||||||
|
|
||||||
|
#### server_ports
|
||||||
|
|
||||||
|
!!! question "Since sing-box 1.12.0"
|
||||||
|
|
||||||
|
Server port range list.
|
||||||
|
|
||||||
|
Conflicts with `server_port`.
|
||||||
|
|
||||||
|
#### hop_interval
|
||||||
|
|
||||||
|
!!! question "Since sing-box 1.12.0"
|
||||||
|
|
||||||
|
Port hopping interval.
|
||||||
|
|
||||||
|
`30s` is used by default.
|
||||||
|
|
||||||
#### up, down
|
#### up, down
|
||||||
|
|
||||||
==Required==
|
==Required==
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
---
|
||||||
|
icon: material/new-box
|
||||||
|
---
|
||||||
|
|
||||||
|
!!! quote "sing-box 1.12.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": "100 Mbps",
|
"up": "100 Mbps",
|
||||||
"up_mbps": 100,
|
"up_mbps": 100,
|
||||||
"down": "100 Mbps",
|
"down": "100 Mbps",
|
||||||
@ -38,6 +51,22 @@
|
|||||||
|
|
||||||
服务器端口。
|
服务器端口。
|
||||||
|
|
||||||
|
#### server_ports
|
||||||
|
|
||||||
|
!!! question "自 sing-box 1.12.0 起"
|
||||||
|
|
||||||
|
服务器端口范围列表。
|
||||||
|
|
||||||
|
与 `server_port` 冲突。
|
||||||
|
|
||||||
|
#### hop_interval
|
||||||
|
|
||||||
|
!!! question "自 sing-box 1.12.0 起"
|
||||||
|
|
||||||
|
端口跳跃间隔。
|
||||||
|
|
||||||
|
默认使用 `30s`。
|
||||||
|
|
||||||
#### up, down
|
#### up, down
|
||||||
|
|
||||||
==必填==
|
==必填==
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package option
|
package option
|
||||||
|
|
||||||
import "github.com/sagernet/sing/common/byteformats"
|
import (
|
||||||
|
"github.com/sagernet/sing/common/byteformats"
|
||||||
|
"github.com/sagernet/sing/common/json/badoption"
|
||||||
|
)
|
||||||
|
|
||||||
type HysteriaInboundOptions struct {
|
type HysteriaInboundOptions struct {
|
||||||
ListenOptions
|
ListenOptions
|
||||||
@ -26,6 +29,8 @@ type HysteriaUser struct {
|
|||||||
type HysteriaOutboundOptions struct {
|
type HysteriaOutboundOptions struct {
|
||||||
DialerOptions
|
DialerOptions
|
||||||
ServerOptions
|
ServerOptions
|
||||||
|
ServerPorts badoption.Listable[string] `json:"server_ports,omitempty"`
|
||||||
|
HopInterval badoption.Duration `json:"hop_interval,omitempty"`
|
||||||
Up *byteformats.NetworkBytesCompat `json:"up,omitempty"`
|
Up *byteformats.NetworkBytesCompat `json:"up,omitempty"`
|
||||||
UpMbps int `json:"up_mbps,omitempty"`
|
UpMbps int `json:"up_mbps,omitempty"`
|
||||||
Down *byteformats.NetworkBytesCompat `json:"down,omitempty"`
|
Down *byteformats.NetworkBytesCompat `json:"down,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"
|
||||||
@ -69,17 +70,18 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
|||||||
receiveBps = uint64(options.DownMbps) * hysteria.MbpsToBps
|
receiveBps = uint64(options.DownMbps) * hysteria.MbpsToBps
|
||||||
}
|
}
|
||||||
client, err := hysteria.NewClient(hysteria.ClientOptions{
|
client, err := hysteria.NewClient(hysteria.ClientOptions{
|
||||||
Context: ctx,
|
Context: ctx,
|
||||||
Dialer: outboundDialer,
|
Dialer: outboundDialer,
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
ServerAddress: options.ServerOptions.Build(),
|
ServerAddress: options.ServerOptions.Build(),
|
||||||
SendBPS: sendBps,
|
ServerPorts: options.ServerPorts,
|
||||||
ReceiveBPS: receiveBps,
|
HopInterval: time.Duration(options.HopInterval),
|
||||||
XPlusPassword: options.Obfs,
|
SendBPS: sendBps,
|
||||||
Password: password,
|
ReceiveBPS: receiveBps,
|
||||||
TLSConfig: tlsConfig,
|
XPlusPassword: options.Obfs,
|
||||||
UDPDisabled: !common.Contains(networkList, N.NetworkUDP),
|
Password: password,
|
||||||
|
TLSConfig: tlsConfig,
|
||||||
|
UDPDisabled: !common.Contains(networkList, N.NetworkUDP),
|
||||||
ConnReceiveWindow: options.ReceiveWindowConn,
|
ConnReceiveWindow: options.ReceiveWindowConn,
|
||||||
StreamReceiveWindow: options.ReceiveWindow,
|
StreamReceiveWindow: options.ReceiveWindow,
|
||||||
DisableMTUDiscovery: options.DisableMTUDiscovery,
|
DisableMTUDiscovery: options.DisableMTUDiscovery,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user