[FEAT] Add geodata loader mode switch
This commit is contained in:
parent
e3a61dbbd3
commit
b75e8f9500
3 changed files with 15 additions and 13 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/adapter"
|
"github.com/Dreamacro/clash/adapter"
|
||||||
"github.com/Dreamacro/clash/adapter/outbound"
|
"github.com/Dreamacro/clash/adapter/outbound"
|
||||||
|
@ -309,7 +310,7 @@ func ParseRawConfig(rawCfg *RawConfig) (*Config, error) {
|
||||||
|
|
||||||
func parseGeneral(cfg *RawConfig) (*General, error) {
|
func parseGeneral(cfg *RawConfig) (*General, error) {
|
||||||
externalUI := cfg.ExternalUI
|
externalUI := cfg.ExternalUI
|
||||||
|
geodata.SetLoader(cfg.GeodataLoader)
|
||||||
// checkout externalUI exist
|
// checkout externalUI exist
|
||||||
if externalUI != "" {
|
if externalUI != "" {
|
||||||
externalUI = C.Path.Resolve(externalUI)
|
externalUI = C.Path.Resolve(externalUI)
|
||||||
|
@ -339,6 +340,7 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
||||||
LogLevel: cfg.LogLevel,
|
LogLevel: cfg.LogLevel,
|
||||||
IPv6: cfg.IPv6,
|
IPv6: cfg.IPv6,
|
||||||
Interface: cfg.Interface,
|
Interface: cfg.Interface,
|
||||||
|
GeodataLoader: cfg.GeodataLoader,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,6 +488,7 @@ time = ClashTime()
|
||||||
func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[string]*providerTypes.RuleProvider, error) {
|
func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[string]*providerTypes.RuleProvider, error) {
|
||||||
ruleProviders := map[string]*providerTypes.RuleProvider{}
|
ruleProviders := map[string]*providerTypes.RuleProvider{}
|
||||||
|
|
||||||
|
startTime := time.Now()
|
||||||
// parse rule provider
|
// parse rule provider
|
||||||
for name, mapping := range cfg.RuleProvider {
|
for name, mapping := range cfg.RuleProvider {
|
||||||
rp, err := RP.ParseRuleProvider(name, mapping)
|
rp, err := RP.ParseRuleProvider(name, mapping)
|
||||||
|
@ -560,7 +563,9 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, map[strin
|
||||||
rules = append(rules, parsed)
|
rules = append(rules, parsed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elapsedTime := time.Since(startTime) / time.Millisecond // duration in ms
|
||||||
|
log.Infoln("Initialization time consuming %dms", elapsedTime) //Segment finished in xxm
|
||||||
|
log.Infoln("Geodata Loader mode: %s", geodata.LoaderName())
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
return rules, ruleProviders, nil
|
return rules, ruleProviders, nil
|
||||||
|
|
|
@ -78,11 +78,11 @@ func ApplyConfig(cfg *config.Config, force bool) {
|
||||||
|
|
||||||
updateUsers(cfg.Users)
|
updateUsers(cfg.Users)
|
||||||
updateHosts(cfg.Hosts)
|
updateHosts(cfg.Hosts)
|
||||||
|
updateGeneral(cfg.General, cfg.Tun, force)
|
||||||
updateProxies(cfg.Proxies, cfg.Providers)
|
updateProxies(cfg.Proxies, cfg.Providers)
|
||||||
updateRules(cfg.Rules, cfg.RuleProviders)
|
updateRules(cfg.Rules, cfg.RuleProviders)
|
||||||
updateIPTables(cfg.DNS, cfg.General, cfg.Tun)
|
updateIPTables(cfg.DNS, cfg.General, cfg.Tun)
|
||||||
updateDNS(cfg.DNS, cfg.Tun)
|
updateDNS(cfg.DNS, cfg.Tun)
|
||||||
updateGeneral(cfg.General, cfg.Tun, force)
|
|
||||||
updateTun(cfg.Tun)
|
updateTun(cfg.Tun)
|
||||||
updateExperimental(cfg)
|
updateExperimental(cfg)
|
||||||
loadProvider(cfg.RuleProviders, cfg.Providers)
|
loadProvider(cfg.RuleProviders, cfg.Providers)
|
||||||
|
@ -242,9 +242,6 @@ func updateGeneral(general *config.General, Tun *config.Tun, force bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
geodataLoader := general.GeodataLoader
|
|
||||||
G.SetLoader(geodataLoader)
|
|
||||||
|
|
||||||
allowLan := general.AllowLan
|
allowLan := general.AllowLan
|
||||||
P.SetAllowLan(allowLan)
|
P.SetAllowLan(allowLan)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue