mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-14 04:19:36 +03:00
Fix: TFO AsIs bug (#452)
This commit is contained in:
@ -8,12 +8,12 @@ const (
|
||||
TCP_FASTOPEN = 15
|
||||
)
|
||||
|
||||
func setTFO(fd syscall.Handle, tfo int32) error {
|
||||
func setTFO(fd syscall.Handle, tfo int) error {
|
||||
if tfo > 0 {
|
||||
tfo = 1
|
||||
}
|
||||
if tfo >= 0 {
|
||||
if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, TCP_FASTOPEN, int(tfo)); err != nil {
|
||||
if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, TCP_FASTOPEN, tfo); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,7 @@ func setTFO(fd syscall.Handle, tfo int32) error {
|
||||
|
||||
func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
|
||||
if isTCPSocket(network) {
|
||||
if err := setTFO(syscall.Handle(fd), config.Tfo); err != nil {
|
||||
if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
|
||||
|
||||
func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error {
|
||||
if isTCPSocket(network) {
|
||||
if err := setTFO(syscall.Handle(fd), config.Tfo); err != nil {
|
||||
if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user