mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-05 21:47:31 +00:00
feat: add ip-version param
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package dialer
|
||||
|
||||
import "go.uber.org/atomic"
|
||||
import (
|
||||
"go.uber.org/atomic"
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultOptions []Option
|
||||
@@ -13,6 +15,8 @@ type option struct {
|
||||
addrReuse bool
|
||||
routingMark int
|
||||
direct bool
|
||||
network int
|
||||
prefer int
|
||||
}
|
||||
|
||||
type Option func(opt *option)
|
||||
@@ -40,3 +44,25 @@ func WithDirect() Option {
|
||||
opt.direct = true
|
||||
}
|
||||
}
|
||||
|
||||
func WithPreferIPv4() Option {
|
||||
return func(opt *option) {
|
||||
opt.prefer = 4
|
||||
}
|
||||
}
|
||||
|
||||
func WithPreferIPv6() Option {
|
||||
return func(opt *option) {
|
||||
opt.prefer = 6
|
||||
}
|
||||
}
|
||||
|
||||
func WithOnlySingleStack(isIPv4 bool) Option {
|
||||
return func(opt *option) {
|
||||
if isIPv4 {
|
||||
opt.network = 4
|
||||
} else {
|
||||
opt.network = 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user