Merge pull request #22 from Adlyq/Alpha-pr

[skip ci]
[Fix] skip when country code not found in GeoIP.dat
This commit is contained in:
gVisor bot 2022-03-22 00:33:02 +08:00
commit 81363e3dfc
4 changed files with 14 additions and 13 deletions

View file

@ -440,13 +440,6 @@ func parseProxies(cfg *RawConfig) (proxies map[string]C.Proxy, providersMap map[
providersMap[name] = pd providersMap[name] = pd
} }
for _, proxyProvider := range providersMap {
log.Infoln("Start initial provider %s", proxyProvider.Name())
if err := proxyProvider.Initial(); err != nil {
return nil, nil, fmt.Errorf("initial proxy provider %s error: %w", proxyProvider.Name(), err)
}
}
// parse proxy group // parse proxy group
for idx, mapping := range groupsConfig { for idx, mapping := range groupsConfig {
group, err := outboundgroup.ParseProxyGroup(mapping, proxies, providersMap) group, err := outboundgroup.ParseProxyGroup(mapping, proxies, providersMap)

View file

@ -77,8 +77,8 @@ func ApplyConfig(cfg *config.Config, force bool) {
updateUsers(cfg.Users) updateUsers(cfg.Users)
updateProxies(cfg.Proxies, cfg.Providers) updateProxies(cfg.Proxies, cfg.Providers)
updateRules(cfg.Rules, cfg.RuleProviders) updateRules(cfg.Rules, cfg.RuleProviders)
updateGeneral(cfg.General, force)
updateDNS(cfg.DNS, cfg.Tun) updateDNS(cfg.DNS, cfg.Tun)
updateGeneral(cfg.General, force)
updateTun(cfg.Tun) updateTun(cfg.Tun)
autoUpdateIPTables(cfg.DNS, cfg.General, cfg.Tun) autoUpdateIPTables(cfg.DNS, cfg.General, cfg.Tun)
updateExperimental(cfg) updateExperimental(cfg)

View file

@ -85,6 +85,9 @@ func parseRule(tp, payload, target string, params []string) (C.Rule, error) {
default: default:
parseErr = fmt.Errorf("unsupported rule type %s", tp) parseErr = fmt.Errorf("unsupported rule type %s", tp)
} }
if parseErr != nil {
return nil, parseErr
}
ruleExtra := &C.RuleExtra{ ruleExtra := &C.RuleExtra{
Network: RC.FindNetwork(params), Network: RC.FindNetwork(params),
SourceIPs: RC.FindSourceIPs(params), SourceIPs: RC.FindSourceIPs(params),

View file

@ -6,6 +6,7 @@ import (
"github.com/Dreamacro/clash/component/trie" "github.com/Dreamacro/clash/component/trie"
C "github.com/Dreamacro/clash/constant" C "github.com/Dreamacro/clash/constant"
P "github.com/Dreamacro/clash/constant/provider" P "github.com/Dreamacro/clash/constant/provider"
"github.com/Dreamacro/clash/log"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
"runtime" "runtime"
"strings" "strings"
@ -129,7 +130,12 @@ func NewRuleSetProvider(name string, behavior P.RuleType, interval time.Duration
return err return err
} }
rp.count = len(rulesRaw) if rp.behavior == P.Classical {
rp.count = len(rules.([]C.Rule))
} else {
rp.count = len(rulesRaw)
}
rp.setRules(rules) rp.setRules(rules)
return nil return nil
} }
@ -201,13 +207,12 @@ func handleClassicalRules(rules []string) (interface{}, error) {
var classicalRules []C.Rule var classicalRules []C.Rule
for _, rawRule := range rules { for _, rawRule := range rules {
ruleType, rule, params := ruleParse(rawRule) ruleType, rule, params := ruleParse(rawRule)
if ruleType == "RULE-SET" {
return nil, errors.New("error rule type")
}
r, err := parseRule(ruleType, rule, "", params) r, err := parseRule(ruleType, rule, "", params)
if err != nil { if err != nil {
return nil, err //return nil, err
log.Warnln("%s", err)
continue
} }
classicalRules = append(classicalRules, r) classicalRules = append(classicalRules, r)