mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-08 04:18:40 +00:00
Add tcpWindowClamp
to sockopt
(#1757)
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
parent
836e84b851
commit
c3322294be
4 changed files with 49 additions and 23 deletions
transport/internet
|
@ -46,7 +46,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
return newError("failed to set SO_MARK").Base(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if config.Interface != "" {
|
||||
if err := syscall.BindToDevice(int(fd), config.Interface); err != nil {
|
||||
return newError("failed to set Interface").Base(err)
|
||||
|
@ -89,6 +89,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
|||
return newError("failed to set TCP_CONGESTION", err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpWindowClamp > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil {
|
||||
return newError("failed to set TCP_WINDOW_CLAMP", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
@ -139,6 +145,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
|
|||
return newError("failed to set TCP_CONGESTION", err)
|
||||
}
|
||||
}
|
||||
|
||||
if config.TcpWindowClamp > 0 {
|
||||
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil {
|
||||
return newError("failed to set TCP_WINDOW_CLAMP", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if config.Tproxy.IsEnabled() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue