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:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user