github.com/metacubex/mihomo@v1.18.5/adapter/inbound/listen.go (about)

     1  package inbound
     2  
     3  import (
     4  	"context"
     5  	"net"
     6  
     7  	"github.com/metacubex/tfo-go"
     8  )
     9  
    10  var (
    11  	lc = tfo.ListenConfig{
    12  		DisableTFO: true,
    13  	}
    14  )
    15  
    16  func SetTfo(open bool) {
    17  	lc.DisableTFO = !open
    18  }
    19  
    20  func SetMPTCP(open bool) {
    21  	setMultiPathTCP(&lc.ListenConfig, open)
    22  }
    23  
    24  func ListenContext(ctx context.Context, network, address string) (net.Listener, error) {
    25  	return lc.Listen(ctx, network, address)
    26  }
    27  
    28  func Listen(network, address string) (net.Listener, error) {
    29  	return ListenContext(context.Background(), network, address)
    30  }