github.com/igoogolx/clash@v1.19.8/component/dialer/options.go (about)

     1  package dialer
     2  
     3  import "go.uber.org/atomic"
     4  
     5  var (
     6  	DefaultOptions     []Option
     7  	DefaultInterface   = atomic.NewString("")
     8  	DefaultRoutingMark = atomic.NewInt32(0)
     9  )
    10  
    11  type option struct {
    12  	interfaceName string
    13  	fallbackBind  bool
    14  	addrReuse     bool
    15  	routingMark   int
    16  }
    17  
    18  type Option func(opt *option)
    19  
    20  func WithInterface(name string) Option {
    21  	return func(opt *option) {
    22  		opt.interfaceName = name
    23  	}
    24  }
    25  
    26  func WithFallbackBind(fallback bool) Option {
    27  	return func(opt *option) {
    28  		opt.fallbackBind = fallback
    29  	}
    30  }
    31  
    32  func WithAddrReuse(reuse bool) Option {
    33  	return func(opt *option) {
    34  		opt.addrReuse = reuse
    35  	}
    36  }
    37  
    38  func WithRoutingMark(mark int) Option {
    39  	return func(opt *option) {
    40  		opt.routingMark = mark
    41  	}
    42  }