diff --git a/component/geodata/utils.go b/component/geodata/utils.go index 1784fcee..1cf7c63c 100644 --- a/component/geodata/utils.go +++ b/component/geodata/utils.go @@ -5,8 +5,19 @@ import ( "strings" ) +var geoLoaderName = "memconservative" + +// geoLoaderName = "standard" + +func LoaderName() string { + return geoLoaderName +} + +func SetLoader(newLoader string) { + geoLoaderName = newLoader +} + func LoadGeoSiteMatcher(countryCode string) (*router.DomainMatcher, int, error) { - geoLoaderName := "memconservative" geoLoader, err := GetGeoDataLoader(geoLoaderName) if err != nil { return nil, 0, err @@ -31,7 +42,6 @@ func LoadGeoSiteMatcher(countryCode string) (*router.DomainMatcher, int, error) } func LoadGeoIPMatcher(country string) (*router.GeoIPMatcher, int, error) { - geoLoaderName := "memconservative" geoLoader, err := GetGeoDataLoader(geoLoaderName) if err != nil { return nil, 0, err diff --git a/config/config.go b/config/config.go index 99c2de9e..292a957e 100644 --- a/config/config.go +++ b/config/config.go @@ -35,12 +35,12 @@ import ( type General struct { Inbound Controller - Mode T.TunnelMode `json:"mode"` - UnifiedDelay bool - LogLevel log.LogLevel `json:"log-level"` - IPv6 bool `json:"ipv6"` - Interface string `json:"-"` - Geodataload string `json:"geodataload"` + Mode T.TunnelMode `json:"mode"` + UnifiedDelay bool + LogLevel log.LogLevel `json:"log-level"` + IPv6 bool `json:"ipv6"` + Interface string `json:"-"` + GeodataLoader string `json:"geodata-loader"` } // Inbound @@ -170,7 +170,7 @@ type RawConfig struct { ExternalUI string `yaml:"external-ui"` Secret string `yaml:"secret"` Interface string `yaml:"interface-name"` - Geodataloader string `yaml:"geodata-loader"` + GeodataLoader string `yaml:"geodata-loader"` ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"` RuleProvider map[string]map[string]interface{} `yaml:"rule-providers"` @@ -201,7 +201,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) { AllowLan: false, BindAddress: "*", Mode: T.Rule, - Geodataloader: "standard", + GeodataLoader: "memconservative", UnifiedDelay: false, Authentication: []string{}, LogLevel: log.INFO, diff --git a/dns/filters.go b/dns/filters.go index cc814ebd..58b37bc4 100644 --- a/dns/filters.go +++ b/dns/filters.go @@ -21,7 +21,7 @@ var geoIPMatcher *router.GeoIPMatcher func (gf *geoipFilter) Match(ip net.IP) bool { if geoIPMatcher == nil { countryCode := "cn" - geoLoader, err := geodata.GetGeoDataLoader("standard") + geoLoader, err := geodata.GetGeoDataLoader(geodata.LoaderName()) if err != nil { log.Errorln("[GeoIPFilter] GetGeoDataLoader error: %s", err.Error()) return false diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 7f37a833..378f5cbf 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -2,6 +2,7 @@ package executor import ( "fmt" + "net" "os" "runtime" @@ -15,6 +16,7 @@ import ( "github.com/Dreamacro/clash/adapter/outboundgroup" "github.com/Dreamacro/clash/component/auth" "github.com/Dreamacro/clash/component/dialer" + G "github.com/Dreamacro/clash/component/geodata" "github.com/Dreamacro/clash/component/iface" "github.com/Dreamacro/clash/component/profile" "github.com/Dreamacro/clash/component/profile/cachefile" @@ -106,9 +108,10 @@ func GetGeneral() *config.General { AllowLan: P.AllowLan(), BindAddress: P.BindAddress(), }, - Mode: tunnel.Mode(), - LogLevel: log.Level(), - IPv6: !resolver.DisableIPv6, + Mode: tunnel.Mode(), + LogLevel: log.Level(), + IPv6: !resolver.DisableIPv6, + GeodataLoader: G.LoaderName(), } return general @@ -239,6 +242,9 @@ func updateGeneral(general *config.General, Tun *config.Tun, force bool) { return } + geodataLoader := general.GeodataLoader + G.SetLoader(geodataLoader) + allowLan := general.AllowLan P.SetAllowLan(allowLan) diff --git a/rule/common/process.go b/rule/common/process.go index 51e12ef5..6398a1a7 100644 --- a/rule/common/process.go +++ b/rule/common/process.go @@ -27,10 +27,8 @@ func (ps *Process) Match(metadata *C.Metadata) bool { if metadata.Process != "" { return strings.EqualFold(metadata.Process, ps.process) } - // ignore match in proxy type "tproxy" - //if metadata.Type == C.TPROXY || !C.AutoIptables { - if metadata.Type == C.TPROXY || C.AutoIptables == "Enable" { + if C.AutoIptables == "Enable" { return false }