mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-15 21:00:27 +00:00
mieru: add mtu and handshake_mode options
This commit is contained in:
@@ -19,6 +19,7 @@ icon: material/new-box
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"traffic_pattern": "GgQIARAK",
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -47,3 +48,7 @@ A base64 string to fine tune network behavior.
|
|||||||
#### user_hint_is_mandatory
|
#### user_hint_is_mandatory
|
||||||
|
|
||||||
If proxy client doesn't sent user hint, proxy server will refuse the connection.
|
If proxy client doesn't sent user hint, proxy server will refuse the connection.
|
||||||
|
|
||||||
|
#### mtu
|
||||||
|
|
||||||
|
Maximum transmission unit of L2 payload. Only applies to UDP transport egress traffic.
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ icon: material/new-box
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"traffic_pattern": "GgQIARAK",
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -47,3 +48,7 @@ icon: material/new-box
|
|||||||
#### user_hint_is_mandatory
|
#### user_hint_is_mandatory
|
||||||
|
|
||||||
客户端若不发送用户提示,代理服务器将拒绝连接。
|
客户端若不发送用户提示,代理服务器将拒绝连接。
|
||||||
|
|
||||||
|
#### mtu
|
||||||
|
|
||||||
|
L2 载荷的最大传输单元。仅适用于 UDP 传输方式的出站流量。
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ icon: material/new-box
|
|||||||
"password": "hjkl",
|
"password": "hjkl",
|
||||||
"multiplexing": "MULTIPLEXING_LOW",
|
"multiplexing": "MULTIPLEXING_LOW",
|
||||||
"traffic_pattern": "GgQIARAK",
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400,
|
||||||
|
"handshake_mode": "HANDSHAKE_STANDARD",
|
||||||
|
|
||||||
... // Dial Fields
|
... // Dial Fields
|
||||||
}
|
}
|
||||||
@@ -71,6 +73,14 @@ Multiplexing level. Supported values are `MULTIPLEXING_OFF`, `MULTIPLEXING_LOW`,
|
|||||||
|
|
||||||
A base64 string to fine tune network behavior.
|
A base64 string to fine tune network behavior.
|
||||||
|
|
||||||
|
#### mtu
|
||||||
|
|
||||||
|
Maximum transmission unit of L2 payload. Only applies to UDP transport egress traffic.
|
||||||
|
|
||||||
|
#### handshake_mode
|
||||||
|
|
||||||
|
Handshake mode when the client opens a connection. Allowed values are `HANDSHAKE_STANDARD` (1-RTT, wait for the proxy server to establish the connection to the destination before sending payload) and `HANDSHAKE_NO_WAIT` (0-RTT, send payload together with the connection to the proxy server).
|
||||||
|
|
||||||
### Dial Fields
|
### Dial Fields
|
||||||
|
|
||||||
See [Dial Fields](/configuration/shared/dial/) for details.
|
See [Dial Fields](/configuration/shared/dial/) for details.
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ icon: material/new-box
|
|||||||
"password": "hjkl",
|
"password": "hjkl",
|
||||||
"multiplexing": "MULTIPLEXING_LOW",
|
"multiplexing": "MULTIPLEXING_LOW",
|
||||||
"traffic_pattern": "GgQIARAK",
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400,
|
||||||
|
"handshake_mode": "HANDSHAKE_STANDARD",
|
||||||
|
|
||||||
... // 拨号字段
|
... // 拨号字段
|
||||||
}
|
}
|
||||||
@@ -71,6 +73,14 @@ mieru 密码。
|
|||||||
|
|
||||||
一个 base64 字符串用于微调网络行为。
|
一个 base64 字符串用于微调网络行为。
|
||||||
|
|
||||||
|
#### mtu
|
||||||
|
|
||||||
|
L2 载荷的最大传输单元。仅适用于 UDP 传输方式的出站流量。
|
||||||
|
|
||||||
|
#### handshake_mode
|
||||||
|
|
||||||
|
客户端建立连接时的握手模式。可设为 `HANDSHAKE_STANDARD`(1-RTT,客户端等待代理服务器建立到目标地址的连接后再发送载荷)或 `HANDSHAKE_NO_WAIT`(0-RTT,客户端在连接代理服务器的同时发送载荷)。
|
||||||
|
|
||||||
### 拨号字段
|
### 拨号字段
|
||||||
|
|
||||||
参阅 [拨号字段](/zh/configuration/shared/dial/)。
|
参阅 [拨号字段](/zh/configuration/shared/dial/)。
|
||||||
|
|||||||
@@ -36,7 +36,10 @@
|
|||||||
// valid: MULTIPLEXING_DEFAULT / MULTIPLEXING_OFF / MULTIPLEXING_LOW
|
// valid: MULTIPLEXING_DEFAULT / MULTIPLEXING_OFF / MULTIPLEXING_LOW
|
||||||
// MULTIPLEXING_MIDDLE / MULTIPLEXING_HIGH
|
// MULTIPLEXING_MIDDLE / MULTIPLEXING_HIGH
|
||||||
"multiplexing": "MULTIPLEXING_LOW",
|
"multiplexing": "MULTIPLEXING_LOW",
|
||||||
"traffic_pattern": "GgQIARAK"
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400,
|
||||||
|
// valid: HANDSHAKE_DEFAULT / HANDSHAKE_STANDARD / HANDSHAKE_NO_WAIT
|
||||||
|
"handshake_mode": "HANDSHAKE_STANDARD"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"route": {
|
"route": {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
"password": "password"
|
"password": "password"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"traffic_pattern": "GgQIARAK"
|
"traffic_pattern": "GgQIARAK",
|
||||||
|
"mtu": 1400
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ type MieruOutboundOptions struct {
|
|||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Multiplexing string `json:"multiplexing,omitempty"`
|
Multiplexing string `json:"multiplexing,omitempty"`
|
||||||
TrafficPattern string `json:"traffic_pattern,omitempty"`
|
TrafficPattern string `json:"traffic_pattern,omitempty"`
|
||||||
|
MTU uint32 `json:"mtu,omitempty"`
|
||||||
|
HandshakeMode string `json:"handshake_mode,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MieruInboundOptions struct {
|
type MieruInboundOptions struct {
|
||||||
@@ -20,6 +22,7 @@ type MieruInboundOptions struct {
|
|||||||
Transport string `json:"transport,omitempty"`
|
Transport string `json:"transport,omitempty"`
|
||||||
TrafficPattern string `json:"traffic_pattern,omitempty"`
|
TrafficPattern string `json:"traffic_pattern,omitempty"`
|
||||||
UserHintIsMandatory bool `json:"user_hint_is_mandatory,omitempty"`
|
UserHintIsMandatory bool `json:"user_hint_is_mandatory,omitempty"`
|
||||||
|
MTU uint32 `json:"mtu,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MieruUser struct {
|
type MieruUser struct {
|
||||||
|
|||||||
@@ -309,13 +309,17 @@ func buildMieruServerConfig(_ context.Context, options option.MieruInboundOption
|
|||||||
UserHintIsMandatory: proto.Bool(true),
|
UserHintIsMandatory: proto.Bool(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
config := &mierupb.ServerConfig{
|
||||||
|
PortBindings: portBindings,
|
||||||
|
Users: users,
|
||||||
|
TrafficPattern: trafficPattern,
|
||||||
|
AdvancedSettings: advancedSettings,
|
||||||
|
}
|
||||||
|
if options.MTU != 0 {
|
||||||
|
config.Mtu = proto.Int32(int32(options.MTU))
|
||||||
|
}
|
||||||
return &mieruserver.ServerConfig{
|
return &mieruserver.ServerConfig{
|
||||||
Config: &mierupb.ServerConfig{
|
Config: config,
|
||||||
PortBindings: portBindings,
|
|
||||||
Users: users,
|
|
||||||
TrafficPattern: trafficPattern,
|
|
||||||
AdvancedSettings: advancedSettings,
|
|
||||||
},
|
|
||||||
}, userNames, nil
|
}, userNames, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,12 @@ func buildMieruClientConfig(options option.MieruOutboundOptions, dialer mieruDia
|
|||||||
Level: mierupb.MultiplexingLevel(multiplexing).Enum(),
|
Level: mierupb.MultiplexingLevel(multiplexing).Enum(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if options.MTU != 0 {
|
||||||
|
config.Profile.Mtu = proto.Int32(int32(options.MTU))
|
||||||
|
}
|
||||||
|
if handshakeMode, ok := mierupb.HandshakeMode_value[options.HandshakeMode]; ok {
|
||||||
|
config.Profile.HandshakeMode = mierupb.HandshakeMode(handshakeMode).Enum()
|
||||||
|
}
|
||||||
if options.TrafficPattern != "" {
|
if options.TrafficPattern != "" {
|
||||||
trafficPattern, _ := mierutp.Decode(options.TrafficPattern)
|
trafficPattern, _ := mierutp.Decode(options.TrafficPattern)
|
||||||
config.Profile.TrafficPattern = trafficPattern
|
config.Profile.TrafficPattern = trafficPattern
|
||||||
@@ -278,6 +284,11 @@ func validateMieruOptions(options option.MieruOutboundOptions) error {
|
|||||||
return fmt.Errorf("invalid multiplexing level: %s", options.Multiplexing)
|
return fmt.Errorf("invalid multiplexing level: %s", options.Multiplexing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if options.HandshakeMode != "" {
|
||||||
|
if _, ok := mierupb.HandshakeMode_value[options.HandshakeMode]; !ok {
|
||||||
|
return fmt.Errorf("invalid handshake mode: %s", options.HandshakeMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
if options.TrafficPattern != "" {
|
if options.TrafficPattern != "" {
|
||||||
trafficPattern, err := mierutp.Decode(options.TrafficPattern)
|
trafficPattern, err := mierutp.Decode(options.TrafficPattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user