2021-09-06 15:07:34 +00:00
|
|
|
package dialer
|
|
|
|
|
2021-11-07 08:48:51 +00:00
|
|
|
import "go.uber.org/atomic"
|
2021-09-06 15:07:34 +00:00
|
|
|
|
2021-11-07 08:48:51 +00:00
|
|
|
var (
|
|
|
|
DefaultOptions []Option
|
|
|
|
DefaultInterface = atomic.NewString("")
|
|
|
|
)
|
|
|
|
|
|
|
|
type option struct {
|
2021-09-06 15:07:34 +00:00
|
|
|
interfaceName string
|
|
|
|
addrReuse bool
|
2021-11-08 08:59:48 +00:00
|
|
|
routingMark int
|
2021-09-06 15:07:34 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 08:48:51 +00:00
|
|
|
type Option func(opt *option)
|
2021-09-06 15:07:34 +00:00
|
|
|
|
|
|
|
func WithInterface(name string) Option {
|
2021-11-07 08:48:51 +00:00
|
|
|
return func(opt *option) {
|
2021-09-06 15:07:34 +00:00
|
|
|
opt.interfaceName = name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func WithAddrReuse(reuse bool) Option {
|
2021-11-07 08:48:51 +00:00
|
|
|
return func(opt *option) {
|
2021-09-06 15:07:34 +00:00
|
|
|
opt.addrReuse = reuse
|
|
|
|
}
|
|
|
|
}
|
2021-11-08 08:59:48 +00:00
|
|
|
|
|
|
|
func WithRoutingMark(mark int) Option {
|
|
|
|
return func(opt *option) {
|
|
|
|
opt.routingMark = mark
|
|
|
|
}
|
|
|
|
}
|