github.com/EagleQL/Xray-core@v1.4.3/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, tfo int) error {
    12  	if tfo > 0 {
    13  		tfo = 1
    14  	}
    15  	if tfo >= 0 {
    16  		if err := syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, TCP_FASTOPEN, tfo); err != nil {
    17  			return err
    18  		}
    19  	}
    20  	return nil
    21  }
    22  
    23  func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
    24  	if isTCPSocket(network) {
    25  		if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil {
    26  			return err
    27  		}
    28  
    29  	}
    30  
    31  	return nil
    32  }
    33  
    34  func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error {
    35  	if isTCPSocket(network) {
    36  		if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil {
    37  			return err
    38  		}
    39  	}
    40  
    41  	return nil
    42  }
    43  
    44  func bindAddr(fd uintptr, ip []byte, port uint32) error {
    45  	return nil
    46  }
    47  
    48  func setReuseAddr(fd uintptr) error {
    49  	return nil
    50  }
    51  
    52  func setReusePort(fd uintptr) error {
    53  	return nil
    54  }