1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-18 03:29:12 -04:00

Feat: custom TCP Fast Open queue length (#1293)

* Feat: custom TCP Fast Open queue length

* Feat: change default TFO queue length to 4096
This commit is contained in:
秋のかえで
2021-09-27 00:29:44 +08:00
committed by Shelikhoo
parent 7d78683d6f
commit be4dd56ac7
5 changed files with 50 additions and 27 deletions

View File

@@ -11,6 +11,7 @@ type SocketConfig struct {
TProxy string `json:"tproxy"`
AcceptProxyProtocol bool `json:"acceptProxyProtocol"`
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
TFOQueueLength uint32 `json:"tcpFastOpenQueueLength"`
}
// Build implements Buildable.
@@ -23,6 +24,12 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
tfoSettings = internet.SocketConfig_Disable
}
}
tfoQueueLength := c.TFOQueueLength
if tfoQueueLength == 0 {
tfoQueueLength = 4096
}
var tproxy internet.SocketConfig_TProxyMode
switch strings.ToLower(c.TProxy) {
case "tproxy":
@@ -36,6 +43,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
return &internet.SocketConfig{
Mark: c.Mark,
Tfo: tfoSettings,
TfoQueueLength: tfoQueueLength,
Tproxy: tproxy,
AcceptProxyProtocol: c.AcceptProxyProtocol,
TcpKeepAliveInterval: c.TCPKeepAliveInterval,

View File

@@ -37,12 +37,14 @@ func TestSocketConfig(t *testing.T) {
{
Input: `{
"mark": 1,
"tcpFastOpen": true
"tcpFastOpen": true,
"tcpFastOpenQueueLength": 1024
}`,
Parser: createParser(),
Output: &internet.SocketConfig{
Mark: 1,
Tfo: internet.SocketConfig_Enable,
Mark: 1,
Tfo: internet.SocketConfig_Enable,
TfoQueueLength: 1024,
},
},
})