0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-12 11:29:36 +03:00

Add tcpMaxSeg to sockopt (#2002)

This commit is contained in:
xqzr
2023-04-30 08:03:30 +08:00
committed by GitHub
parent 18e5b0963f
commit dd81ad5342
4 changed files with 29 additions and 2 deletions

View File

@ -94,6 +94,13 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
return newError("failed to set TCP_USER_TIMEOUT", err)
}
}
if config.TcpMaxSeg > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil {
return newError("failed to set TCP_MAXSEG", err)
}
}
}
if config.Tproxy.IsEnabled() {
@ -156,6 +163,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
return newError("failed to set TCP_USER_TIMEOUT", err)
}
}
if config.TcpMaxSeg > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil {
return newError("failed to set TCP_MAXSEG", err)
}
}
}
if config.Tproxy.IsEnabled() {