mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-22 19:33:32 +02:00
add tcpcongestion
(#1234)
* add `tcpcongestion` * Update sockopt_linux.go * Update config.pb.go * Update transport_internet.go * Update config.pb.go * Update transport_internet.go * Update config.proto
This commit is contained in:
parent
43477109f5
commit
8cf23f1947
4 changed files with 17 additions and 0 deletions
|
@ -533,6 +533,7 @@ type SocketConfig struct {
|
|||
DialerProxy string `json:"dialerProxy"`
|
||||
TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"`
|
||||
TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"`
|
||||
TCPCongestion string `json:"tcpCongestion"`
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
|
@ -581,6 +582,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) {
|
|||
DialerProxy: c.DialerProxy,
|
||||
TcpKeepAliveInterval: c.TCPKeepAliveInterval,
|
||||
TcpKeepAliveIdle: c.TCPKeepAliveIdle,
|
||||
TcpCongestion: c.TCPCongestion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -424,6 +424,7 @@ type SocketConfig struct {
|
|||
DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"`
|
||||
TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"`
|
||||
TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"`
|
||||
TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3 json:"tcp_congestion,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SocketConfig) Reset() {
|
||||
|
|
|
@ -96,4 +96,6 @@ message SocketConfig {
|
|||
int32 tcp_keep_alive_interval = 10;
|
||||
|
||||
int32 tcp_keep_alive_idle = 11;
|
||||
|
||||
string tcp_congestion = 12;
|
||||
}
|
||||
|
|
|
@ -77,6 +77,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
return newError("failed to unset SO_KEEPALIVE", err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpCongestion != "" {
|
||||
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
||||
return newError("failed to set TCP_CONGESTION", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
@ -121,6 +127,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||
return newError("failed to unset SO_KEEPALIVE", err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpCongestion != "" {
|
||||
if err := syscall.SetsockoptString(int(fd), syscall.SOL_TCP, syscall.TCP_CONGESTION, config.TcpCongestion); err != nil {
|
||||
return newError("failed to set TCP_CONGESTION", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
|
Loading…
Reference in a new issue