mihomo/component/dialer/options.go

43 lines
682 B
Go
Raw Normal View History

package dialer
import "go.uber.org/atomic"
var (
DefaultOptions []Option
DefaultInterface = atomic.NewString("")
DefaultRoutingMark = atomic.NewInt32(0)
)
type option struct {
interfaceName string
addrReuse bool
2021-11-08 16:59:48 +08:00
routingMark int
2022-03-28 00:44:13 +08:00
direct bool
}
type Option func(opt *option)
func WithInterface(name string) Option {
return func(opt *option) {
opt.interfaceName = name
}
}
func WithAddrReuse(reuse bool) Option {
return func(opt *option) {
opt.addrReuse = reuse
}
}
2021-11-08 16:59:48 +08:00
func WithRoutingMark(mark int) Option {
return func(opt *option) {
opt.routingMark = mark
}
}
2022-03-28 00:44:13 +08:00
func WithDirect() Option {
return func(opt *option) {
opt.direct = true
}
}