fix: healthy check for proxy provider

This commit is contained in:
yicheng 2021-07-27 22:22:04 +08:00
parent d52e706058
commit efcb64d0ea
3 changed files with 20 additions and 1 deletions

View File

@ -527,6 +527,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
}
ApiRequest.requestProxyProviderList() {
providers in
providers.providers.forEach {
ApiRequest.healthCheck(proxy: $0.key)
}
}
}
}

View File

@ -288,7 +288,7 @@ class ApiRequest {
if res.response?.statusCode == 204 {
Logger.log("HeathCheck for \(proxy) finished")
} else {
Logger.log("HeathCheck for \(proxy) failed")
Logger.log("HeathCheck for \(proxy) failed:\(res.response?.statusCode ?? -1)")
}
completeHandler?()
}

View File

@ -44,6 +44,18 @@ class ProxyGroupSpeedTestMenuItem: NSMenuItem {
@objc func healthCheck() {
guard testType == .reTest else { return }
ApiRequest.healthCheck(proxy: proxyGroup.name)
ApiRequest.getMergedProxyData { [weak self] proxyResp in
guard let self = self else { return }
var providers = Set<ClashProxyName>()
self.proxyGroup.all?.compactMap{
proxyResp?.proxiesMap[$0]?.enclosingProvider?.name
}.forEach{
providers.insert($0)
}
providers.forEach{
ApiRequest.healthCheck(proxy: $0)
}
}
menu?.cancelTracking()
}
}