Optimize: Only add auto group when has more than one proxies .
This commit is contained in:
parent
c68017d604
commit
ce19c5202f
@ -22,6 +22,11 @@ class ConfigFileFactory {
|
||||
|
||||
sampleConfigStr = sampleConfigStr?.replacingOccurrences(of: "{{ProxyPlaceHolder}}", with: proxyStr)
|
||||
sampleConfigStr = sampleConfigStr?.replacingOccurrences(of: "{{ProxyGroupPlaceHolder}}", with: proxyGroupStr)
|
||||
|
||||
if proxies.count > 1 {
|
||||
let autoGroupStr = "ProxyAuto = url-test, \(proxyGroupStr), http://www.google.com/generate_204, 300"
|
||||
sampleConfigStr = sampleConfigStr?.replacingOccurrences(of: "{{ProxyAutoGroupPlaceHolder}}", with: autoGroupStr)
|
||||
}
|
||||
|
||||
return sampleConfigStr!
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ Proxy = select, {{ProxyGroupPlaceHolder}}
|
||||
# url-test select which proxy will be used by benchmarking speed to a URL.
|
||||
# name = url-test, [proxys], url, interval(second)
|
||||
|
||||
ProxyAuto = url-test, {{ProxyGroupPlaceHolder}}, http://www.google.com/generate_204, 300
|
||||
{{ProxyAutoGroupPlaceHolder}}
|
||||
|
||||
|
||||
[Rule]
|
||||
|
@ -132,8 +132,26 @@ class PreferencesWindowController: NSWindowController
|
||||
shakeWindows()
|
||||
return
|
||||
}
|
||||
var vaild = true
|
||||
var remarkSet = Set<String>()
|
||||
remarkSet.insert("Proxy")
|
||||
remarkSet.insert("ProxyAuto")
|
||||
for config in serverConfigs {
|
||||
if remarkSet.contains(config.remark) || !config.isValid() {
|
||||
vaild = false
|
||||
break
|
||||
} else {
|
||||
remarkSet.insert(config.remark)
|
||||
}
|
||||
}
|
||||
|
||||
if (!vaild) {
|
||||
self.shakeWindows()
|
||||
return
|
||||
}
|
||||
|
||||
let str = ConfigFileFactory.configFile(proxies: serverConfigs)
|
||||
ConfigFileFactory.saveToClashConfigFile(str)
|
||||
ConfigFileFactory.saveToClashConfigFile(str: str)
|
||||
window?.performClose(nil)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user