Fix: TFO AsIs bug (#452)

This commit is contained in:
risetechlab 2021-03-31 00:42:02 +08:00 committed by GitHub
parent a9e11075d1
commit b63049f404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 133 additions and 36 deletions

View file

@ -48,7 +48,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
}
if isTCPSocket(network) {
tfo := int(config.Tfo)
tfo := config.ParseTFOValue()
if tfo > 0 {
tfo = 1
}
@ -75,9 +75,10 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
}
}
if isTCPSocket(network) {
if config.Tfo >= 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, TCP_FASTOPEN, int(config.Tfo)); err != nil {
return newError("failed to set TCP_FASTOPEN=", config.Tfo).Base(err)
tfo := config.ParseTFOValue()
if tfo >= 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, TCP_FASTOPEN, tfo); err != nil {
return newError("failed to set TCP_FASTOPEN=", tfo).Base(err)
}
}
}