github.com/chwjbn/xclash@v0.2.0/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  )
     9  
    10  type option struct {
    11  	interfaceName string
    12  	addrReuse     bool
    13  	routingMark   int
    14  }
    15  
    16  type Option func(opt *option)
    17  
    18  func WithInterface(name string) Option {
    19  	return func(opt *option) {
    20  		opt.interfaceName = name
    21  	}
    22  }
    23  
    24  func WithAddrReuse(reuse bool) Option {
    25  	return func(opt *option) {
    26  		opt.addrReuse = reuse
    27  	}
    28  }
    29  
    30  func WithRoutingMark(mark int) Option {
    31  	return func(opt *option) {
    32  		opt.routingMark = mark
    33  	}
    34  }