github.com/metacubex/mihomo@v1.18.5/listener/config/tun.go (about) 1 package config 2 3 import ( 4 "net/netip" 5 6 C "github.com/metacubex/mihomo/constant" 7 ) 8 9 func StringSliceToNetipPrefixSlice(ss []string) ([]netip.Prefix, error) { 10 lps := make([]netip.Prefix, 0, len(ss)) 11 for _, s := range ss { 12 prefix, err := netip.ParsePrefix(s) 13 if err != nil { 14 return nil, err 15 } 16 lps = append(lps, prefix) 17 } 18 return lps, nil 19 } 20 21 type Tun struct { 22 Enable bool `yaml:"enable" json:"enable"` 23 Device string `yaml:"device" json:"device"` 24 Stack C.TUNStack `yaml:"stack" json:"stack"` 25 DNSHijack []string `yaml:"dns-hijack" json:"dns-hijack"` 26 AutoRoute bool `yaml:"auto-route" json:"auto-route"` 27 AutoDetectInterface bool `yaml:"auto-detect-interface" json:"auto-detect-interface"` 28 RedirectToTun []string `yaml:"-" json:"-"` 29 30 MTU uint32 `yaml:"mtu" json:"mtu,omitempty"` 31 GSO bool `yaml:"gso" json:"gso,omitempty"` 32 GSOMaxSize uint32 `yaml:"gso-max-size" json:"gso-max-size,omitempty"` 33 Inet4Address []netip.Prefix `yaml:"inet4-address" json:"inet4-address,omitempty"` 34 Inet6Address []netip.Prefix `yaml:"inet6-address" json:"inet6-address,omitempty"` 35 StrictRoute bool `yaml:"strict-route" json:"strict-route,omitempty"` 36 Inet4RouteAddress []netip.Prefix `yaml:"inet4-route-address" json:"inet4-route-address,omitempty"` 37 Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"` 38 Inet4RouteExcludeAddress []netip.Prefix `yaml:"inet4-route-exclude-address" json:"inet4-route-exclude-address,omitempty"` 39 Inet6RouteExcludeAddress []netip.Prefix `yaml:"inet6-route-exclude-address" json:"inet6-route-exclude-address,omitempty"` 40 IncludeInterface []string `yaml:"include-interface" json:"include-interface,omitempty"` 41 ExcludeInterface []string `yaml:"exclude-interface" json:"exclude-interface,omitempty"` 42 IncludeUID []uint32 `yaml:"include-uid" json:"include-uid,omitempty"` 43 IncludeUIDRange []string `yaml:"include-uid-range" json:"include-uid-range,omitempty"` 44 ExcludeUID []uint32 `yaml:"exclude-uid" json:"exclude-uid,omitempty"` 45 ExcludeUIDRange []string `yaml:"exclude-uid-range" json:"exclude-uid-range,omitempty"` 46 IncludeAndroidUser []int `yaml:"include-android-user" json:"include-android-user,omitempty"` 47 IncludePackage []string `yaml:"include-package" json:"include-package,omitempty"` 48 ExcludePackage []string `yaml:"exclude-package" json:"exclude-package,omitempty"` 49 EndpointIndependentNat bool `yaml:"endpoint-independent-nat" json:"endpoint-independent-nat,omitempty"` 50 UDPTimeout int64 `yaml:"udp-timeout" json:"udp-timeout,omitempty"` 51 FileDescriptor int `yaml:"file-descriptor" json:"file-descriptor"` 52 TableIndex int `yaml:"table-index" json:"table-index"` 53 }