Skip to content

Commit

Permalink
fix rule
Browse files Browse the repository at this point in the history
  • Loading branch information
naicfeng committed Mar 27, 2020
1 parent 403748b commit a19a276
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
gTargetSdkVersion = 29

gVersionCode = 10111
gVersionName = "1.1.10R2"
gVersionName = "1.1.10R3"

gKotlinVersion = '1.3.61'
gKotlinCoroutineVersion = '1.3.3'
Expand Down
36 changes: 18 additions & 18 deletions core/src/main/golang/clash/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ type RawConfig struct {
ExternalUI string `yaml:"external-ui"`
Secret string `yaml:"secret"`

ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
ProxyProvider map[string]map[string]interface{} `yaml:"proxy-provider"`
Hosts map[string]string `yaml:"hosts"`
DNS RawDNS `yaml:"dns"`
Tun Tun `yaml:"tun"`
Tun Tun `yaml:"tun"`
Experimental Experimental `yaml:"experimental"`
Proxy []map[string]interface{} `yaml:"proxies"`
ProxyGroup []map[string]interface{} `yaml:"proxy-groups"`
Rule []string `yaml:"rules"`

// remove after 1.0
ProxyProviderOld map[string]map[string]interface{} `yaml:"proxy-provider"`
ProxyOld []map[string]interface{} `yaml:"Proxy"`
ProxyGroupOld []map[string]interface{} `yaml:"Proxy Group"`
RuleOld []string `yaml:"Rule"`
Proxy []map[string]interface{} `yaml:"Proxy"`
ProxyGroup []map[string]interface{} `yaml:"Proxy Group"`
Rule []string `yaml:"Rule"`

// try fix bridge (default old)
ProxyProviderNew map[string]map[string]interface{} `yaml:"proxy-providers"`
ProxyNew []map[string]interface{} `yaml:"proxies"`
ProxyGroupNew []map[string]interface{} `yaml:"proxy-groups"`
RuleNew []string `yaml:"rules"`
}

// Parse config
Expand Down Expand Up @@ -175,9 +175,9 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
},

// remove after 1.0
RuleOld: []string{},
ProxyOld: []map[string]interface{}{},
ProxyGroupOld: []map[string]interface{}{},
RuleNew: []string{},
ProxyNew: []map[string]interface{}{},
ProxyGroupNew: []map[string]interface{}{},
}

if err := yaml.Unmarshal(buf, &rawCfg); err != nil {
Expand Down Expand Up @@ -274,15 +274,15 @@ func parseProxies(cfg *RawConfig, baseDir string) (proxies map[string]C.Proxy, p
providersConfig := cfg.ProxyProvider

if len(proxiesConfig) == 0 {
proxiesConfig = cfg.ProxyOld
proxiesConfig = cfg.ProxyNew
}

if len(groupsConfig) == 0 {
groupsConfig = cfg.ProxyGroupOld
groupsConfig = cfg.ProxyGroupNew
}

if len(providersConfig) == 0 {
providersConfig = cfg.ProxyProviderOld
providersConfig = cfg.ProxyProviderNew
}

defer func() {
Expand Down Expand Up @@ -394,7 +394,7 @@ func parseRules(cfg *RawConfig, proxies map[string]C.Proxy) ([]C.Rule, error) {

// remove after 1.0
if len(rulesConfig) == 0 {
rulesConfig = cfg.RuleOld
rulesConfig = cfg.RuleNew
}

// parse rules
Expand Down

0 comments on commit a19a276

Please sign in to comment.