diff --git a/hub/route/proxies.go b/hub/route/proxies.go index 69c8e4465..9ff27c2dd 100644 --- a/hub/route/proxies.go +++ b/hub/route/proxies.go @@ -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) +}