1
0
Fork 0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-08 04:18:40 +00:00

Add tcpWindowClamp to sockopt ()

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
xqzr 2023-03-09 21:51:16 +08:00 committed by GitHub
parent 836e84b851
commit c3322294be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 23 deletions
transport/internet

View file

@ -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() {