github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/transport/internet/sockopt_windows.go (about) 1 package internet 2 3 import ( 4 "syscall" 5 ) 6 7 const ( 8 TCP_FASTOPEN = 15 9 ) 10 11 func setTFO(fd syscall.Handle, settings SocketConfig_TCPFastOpenState) error { 12 switch settings { 13 case SocketConfig_Enable: 14 if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, TCP_FASTOPEN, 1); err != nil { 15 return err 16 } 17 case SocketConfig_Disable: 18 if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, TCP_FASTOPEN, 0); err != nil { 19 return err 20 } 21 } 22 return nil 23 } 24 25 func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { 26 if isTCPSocket(network) { 27 if err := setTFO(syscall.Handle(fd), config.Tfo); err != nil { 28 return err 29 } 30 31 } 32 33 return nil 34 } 35 36 func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error { 37 if isTCPSocket(network) { 38 if err := setTFO(syscall.Handle(fd), config.Tfo); err != nil { 39 return err 40 } 41 } 42 43 return nil 44 } 45 46 func bindAddr(fd uintptr, ip []byte, port uint32) error { 47 return nil 48 } 49 50 func setReuseAddr(fd uintptr) error { 51 return nil 52 } 53 54 func setReusePort(fd uintptr) error { 55 return nil 56 }