2022-12-04 14:37:52 +08:00
|
|
|
package config
|
2022-12-04 13:37:14 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
|
2023-11-03 21:01:45 +08:00
|
|
|
C "github.com/metacubex/mihomo/constant"
|
2022-12-04 13:37:14 +08:00
|
|
|
)
|
|
|
|
|
2023-10-10 19:49:16 +08:00
|
|
|
func StringSliceToNetipPrefixSlice(ss []string) ([]netip.Prefix, error) {
|
|
|
|
lps := make([]netip.Prefix, 0, len(ss))
|
2022-12-05 17:43:50 +08:00
|
|
|
for _, s := range ss {
|
|
|
|
prefix, err := netip.ParsePrefix(s)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-10-10 19:49:16 +08:00
|
|
|
lps = append(lps, prefix)
|
2022-12-05 17:43:50 +08:00
|
|
|
}
|
|
|
|
return lps, nil
|
|
|
|
}
|
|
|
|
|
2022-12-04 13:37:14 +08:00
|
|
|
type Tun struct {
|
2022-12-06 09:04:30 +08:00
|
|
|
Enable bool `yaml:"enable" json:"enable"`
|
|
|
|
Device string `yaml:"device" json:"device"`
|
|
|
|
Stack C.TUNStack `yaml:"stack" json:"stack"`
|
|
|
|
DNSHijack []string `yaml:"dns-hijack" json:"dns-hijack"`
|
|
|
|
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
|
|
|
|
AutoDetectInterface bool `yaml:"auto-detect-interface" json:"auto-detect-interface"`
|
|
|
|
RedirectToTun []string `yaml:"-" json:"-"`
|
2022-12-04 13:37:14 +08:00
|
|
|
|
2023-11-02 11:37:40 +08:00
|
|
|
MTU uint32 `yaml:"mtu" json:"mtu,omitempty"`
|
2023-12-10 08:32:54 +08:00
|
|
|
GSO bool `yaml:"gso" json:"gso,omitempty"`
|
|
|
|
GSOMaxSize uint32 `yaml:"gso-max-size" json:"gso-max-size,omitempty"`
|
2023-11-02 11:37:40 +08:00
|
|
|
Inet4Address []netip.Prefix `yaml:"inet4-address" json:"inet4-address,omitempty"`
|
|
|
|
Inet6Address []netip.Prefix `yaml:"inet6-address" json:"inet6-address,omitempty"`
|
|
|
|
StrictRoute bool `yaml:"strict-route" json:"strict-route,omitempty"`
|
|
|
|
Inet4RouteAddress []netip.Prefix `yaml:"inet4-route-address" json:"inet4-route-address,omitempty"`
|
|
|
|
Inet6RouteAddress []netip.Prefix `yaml:"inet6-route-address" json:"inet6-route-address,omitempty"`
|
|
|
|
Inet4RouteExcludeAddress []netip.Prefix `yaml:"inet4-route-exclude-address" json:"inet4-route-exclude-address,omitempty"`
|
|
|
|
Inet6RouteExcludeAddress []netip.Prefix `yaml:"inet6-route-exclude-address" json:"inet6-route-exclude-address,omitempty"`
|
2023-12-10 08:32:54 +08:00
|
|
|
IncludeInterface []string `yaml:"include-interface" json:"include-interface,omitempty"`
|
|
|
|
ExcludeInterface []string `yaml:"exclude-interface" json:"exclude-interface,omitempty"`
|
2023-11-02 11:37:40 +08:00
|
|
|
IncludeUID []uint32 `yaml:"include-uid" json:"include-uid,omitempty"`
|
|
|
|
IncludeUIDRange []string `yaml:"include-uid-range" json:"include-uid-range,omitempty"`
|
|
|
|
ExcludeUID []uint32 `yaml:"exclude-uid" json:"exclude-uid,omitempty"`
|
|
|
|
ExcludeUIDRange []string `yaml:"exclude-uid-range" json:"exclude-uid-range,omitempty"`
|
|
|
|
IncludeAndroidUser []int `yaml:"include-android-user" json:"include-android-user,omitempty"`
|
|
|
|
IncludePackage []string `yaml:"include-package" json:"include-package,omitempty"`
|
|
|
|
ExcludePackage []string `yaml:"exclude-package" json:"exclude-package,omitempty"`
|
|
|
|
EndpointIndependentNat bool `yaml:"endpoint-independent-nat" json:"endpoint-independent-nat,omitempty"`
|
|
|
|
UDPTimeout int64 `yaml:"udp-timeout" json:"udp-timeout,omitempty"`
|
|
|
|
FileDescriptor int `yaml:"file-descriptor" json:"file-descriptor"`
|
2024-03-24 21:31:52 +08:00
|
|
|
TableIndex int `yaml:"table-index" json:"table-index"`
|
2022-12-04 13:37:14 +08:00
|
|
|
}
|