mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 04:23:15 +08:00
chore: Use DELETE to clear the proxy group fixed
This commit is contained in:
parent
acfc9f8baa
commit
af5ad3254b
@ -31,6 +31,7 @@ func proxyRouter() http.Handler {
|
||||
r.Get("/", getProxy)
|
||||
r.Get("/delay", getProxyDelay)
|
||||
r.Put("/", updateProxy)
|
||||
r.Delete("/", unfixedProxy)
|
||||
})
|
||||
return r
|
||||
}
|
||||
@ -146,3 +147,27 @@ func getProxyDelay(w http.ResponseWriter, r *http.Request) {
|
||||
"delay": delay,
|
||||
})
|
||||
}
|
||||
|
||||
func unfixedProxy(w http.ResponseWriter, r *http.Request) {
|
||||
proxy := r.Context().Value(CtxKeyProxy).(C.Proxy)
|
||||
switch proxy.(*adapter.Proxy).Type() {
|
||||
case C.URLTest:
|
||||
if urlTestGroup, ok := proxy.(*adapter.Proxy).ProxyAdapter.(*outboundgroup.URLTest); ok {
|
||||
urlTestGroup.ForceSet("")
|
||||
}
|
||||
case C.Fallback:
|
||||
if fallbackGroup, ok := proxy.(*adapter.Proxy).ProxyAdapter.(*outboundgroup.Fallback); ok {
|
||||
fallbackGroup.ForceSet("")
|
||||
}
|
||||
default:
|
||||
render.Status(r, http.StatusBadRequest)
|
||||
render.JSON(w, r, ErrBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if proxy.(*adapter.Proxy).Type() != C.Selector {
|
||||
cachefile.Cache().SetSelected(proxy.Name(), "")
|
||||
}
|
||||
|
||||
render.NoContent(w, r)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user