mieru: add mtu and handshake_mode options

This commit is contained in:
Shtorm
2026-09-04 01:24:10 +03:00
parent b0ec582349
commit eac79f2080
9 changed files with 60 additions and 8 deletions
+5
View File
@@ -19,6 +19,7 @@ icon: material/new-box
}
],
"traffic_pattern": "GgQIARAK",
"mtu": 1400
}
```
@@ -47,3 +48,7 @@ A base64 string to fine tune network behavior.
#### user_hint_is_mandatory
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.
+5
View File
@@ -19,6 +19,7 @@ icon: material/new-box
}
],
"traffic_pattern": "GgQIARAK",
"mtu": 1400
}
```
@@ -47,3 +48,7 @@ icon: material/new-box
#### user_hint_is_mandatory
客户端若不发送用户提示,代理服务器将拒绝连接。
#### mtu
L2 载荷的最大传输单元。仅适用于 UDP 传输方式的出站流量。
+10
View File
@@ -20,6 +20,8 @@ icon: material/new-box
"password": "hjkl",
"multiplexing": "MULTIPLEXING_LOW",
"traffic_pattern": "GgQIARAK",
"mtu": 1400,
"handshake_mode": "HANDSHAKE_STANDARD",
... // Dial Fields
}
@@ -71,6 +73,14 @@ Multiplexing level. Supported values are `MULTIPLEXING_OFF`, `MULTIPLEXING_LOW`,
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
See [Dial Fields](/configuration/shared/dial/) for details.
+10
View File
@@ -20,6 +20,8 @@ icon: material/new-box
"password": "hjkl",
"multiplexing": "MULTIPLEXING_LOW",
"traffic_pattern": "GgQIARAK",
"mtu": 1400,
"handshake_mode": "HANDSHAKE_STANDARD",
... // 拨号字段
}
@@ -71,6 +73,14 @@ mieru 密码。
一个 base64 字符串用于微调网络行为。
#### mtu
L2 载荷的最大传输单元。仅适用于 UDP 传输方式的出站流量。
#### handshake_mode
客户端建立连接时的握手模式。可设为 `HANDSHAKE_STANDARD`(1-RTT,客户端等待代理服务器建立到目标地址的连接后再发送载荷)或 `HANDSHAKE_NO_WAIT`(0-RTT,客户端在连接代理服务器的同时发送载荷)。
### 拨号字段
参阅 [拨号字段](/zh/configuration/shared/dial/)。
+4 -1
View File
@@ -36,7 +36,10 @@
// valid: MULTIPLEXING_DEFAULT / MULTIPLEXING_OFF / MULTIPLEXING_LOW
// MULTIPLEXING_MIDDLE / MULTIPLEXING_HIGH
"multiplexing": "MULTIPLEXING_LOW",
"traffic_pattern": "GgQIARAK"
"traffic_pattern": "GgQIARAK",
"mtu": 1400,
// valid: HANDSHAKE_DEFAULT / HANDSHAKE_STANDARD / HANDSHAKE_NO_WAIT
"handshake_mode": "HANDSHAKE_STANDARD"
}
],
"route": {
+2 -1
View File
@@ -17,7 +17,8 @@
"password": "password"
}
],
"traffic_pattern": "GgQIARAK"
"traffic_pattern": "GgQIARAK",
"mtu": 1400
}
],
"outbounds": [
+3
View File
@@ -11,6 +11,8 @@ type MieruOutboundOptions struct {
Password string `json:"password,omitempty"`
Multiplexing string `json:"multiplexing,omitempty"`
TrafficPattern string `json:"traffic_pattern,omitempty"`
MTU uint32 `json:"mtu,omitempty"`
HandshakeMode string `json:"handshake_mode,omitempty"`
}
type MieruInboundOptions struct {
@@ -20,6 +22,7 @@ type MieruInboundOptions struct {
Transport string `json:"transport,omitempty"`
TrafficPattern string `json:"traffic_pattern,omitempty"`
UserHintIsMandatory bool `json:"user_hint_is_mandatory,omitempty"`
MTU uint32 `json:"mtu,omitempty"`
}
type MieruUser struct {
+10 -6
View File
@@ -309,13 +309,17 @@ func buildMieruServerConfig(_ context.Context, options option.MieruInboundOption
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{
Config: &mierupb.ServerConfig{
PortBindings: portBindings,
Users: users,
TrafficPattern: trafficPattern,
AdvancedSettings: advancedSettings,
},
Config: config,
}, userNames, nil
}
+11
View File
@@ -235,6 +235,12 @@ func buildMieruClientConfig(options option.MieruOutboundOptions, dialer mieruDia
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 != "" {
trafficPattern, _ := mierutp.Decode(options.TrafficPattern)
config.Profile.TrafficPattern = trafficPattern
@@ -278,6 +284,11 @@ func validateMieruOptions(options option.MieruOutboundOptions) error {
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 != "" {
trafficPattern, err := mierutp.Decode(options.TrafficPattern)
if err != nil {