mirror of
https://github.com/MetaCubeX/metacubexd.git
synced 2024-11-24 09:45:35 +08:00
feat: health check for provider
This commit is contained in:
parent
b4fc1b4c98
commit
03dda3ccad
@ -13,7 +13,8 @@ export default () => {
|
|||||||
updateProxy,
|
updateProxy,
|
||||||
setProxyGroupByProxyName,
|
setProxyGroupByProxyName,
|
||||||
delayTestByProxyGroupName,
|
delayTestByProxyGroupName,
|
||||||
updateProxyProviderByProviderName,
|
updateProviderByProviderName,
|
||||||
|
healthCheckByProviderName,
|
||||||
} = useProxies()
|
} = useProxies()
|
||||||
|
|
||||||
const [collapsedMap, setCollapsedMap] = createSignal<Record<string, boolean>>(
|
const [collapsedMap, setCollapsedMap] = createSignal<Record<string, boolean>>(
|
||||||
@ -33,9 +34,14 @@ export default () => {
|
|||||||
delayTestByProxyGroupName(name)
|
delayTestByProxyGroupName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onHealthCheckClick = (e: MouseEvent, name: string) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
healthCheckByProviderName(name)
|
||||||
|
}
|
||||||
|
|
||||||
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
const onUpdateProviderClick = (e: MouseEvent, name: string) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
updateProxyProviderByProviderName(name)
|
updateProviderByProviderName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -112,14 +118,22 @@ export default () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
<button
|
<button
|
||||||
class="btn btn-circle btn-sm"
|
class="btn btn-circle btn-sm mr-2"
|
||||||
onClick={(e) =>
|
onClick={(e) =>
|
||||||
onUpdateProviderClick(e, proxyProvider.name)
|
onUpdateProviderClick(e, proxyProvider.name)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<IconReload />
|
<IconReload />
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-circle btn-sm"
|
||||||
|
onClick={(e) => onHealthCheckClick(e, proxyProvider.name)}
|
||||||
|
>
|
||||||
|
<IconBrandSpeedtest />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
const content = (
|
const content = (
|
||||||
|
@ -65,19 +65,19 @@ export function useProxies() {
|
|||||||
`group/${proxyGroupName}/delay?url=https%3A%2F%2Fwww.gstatic.com%2Fgenerate_204&timeout=2000`,
|
`group/${proxyGroupName}/delay?url=https%3A%2F%2Fwww.gstatic.com%2Fgenerate_204&timeout=2000`,
|
||||||
)
|
)
|
||||||
.json()
|
.json()
|
||||||
const dMap = delayMap()
|
|
||||||
|
|
||||||
Object.entries(data).forEach(([name, time]) => {
|
setDelayMap({ ...delayMap(), ...data })
|
||||||
dMap[name] = time
|
|
||||||
})
|
|
||||||
|
|
||||||
setDelayMap({ ...dMap })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateProxyProviderByProviderName = async (
|
const updateProviderByProviderName = async (proxyProviderName: string) => {
|
||||||
proxyProviderName: string,
|
await request.put(`providers/proxies/${proxyProviderName}`)
|
||||||
) => {
|
await updateProxy()
|
||||||
await request.put(`/providers/proxies/${proxyProviderName}`)
|
}
|
||||||
|
|
||||||
|
const healthCheckByProviderName = async (providerName: string) => {
|
||||||
|
await request.get(`providers/proxies/${providerName}/healthcheck`, {
|
||||||
|
timeout: 30 * 1000, // thie api was a little bit slow sometimes...
|
||||||
|
})
|
||||||
await updateProxy()
|
await updateProxy()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +89,7 @@ export function useProxies() {
|
|||||||
delayMap,
|
delayMap,
|
||||||
updateProxy,
|
updateProxy,
|
||||||
setProxyGroupByProxyName,
|
setProxyGroupByProxyName,
|
||||||
updateProxyProviderByProviderName,
|
updateProviderByProviderName,
|
||||||
|
healthCheckByProviderName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user