Feature: flush fakeip pool
This commit is contained in:
26
hub/route/cache.go
Normal file
26
hub/route/cache.go
Normal file
@ -0,0 +1,26 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/Dreamacro/clash/component/resolver"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/render"
|
||||
)
|
||||
|
||||
func cacheRouter() http.Handler {
|
||||
r := chi.NewRouter()
|
||||
r.Post("/fakeip/flush", flushFakeIPPool)
|
||||
return r
|
||||
}
|
||||
|
||||
func flushFakeIPPool(w http.ResponseWriter, r *http.Request) {
|
||||
err := resolver.FlushFakeIP()
|
||||
if err != nil {
|
||||
render.Status(r, http.StatusBadRequest)
|
||||
render.JSON(w, r, newError(err.Error()))
|
||||
return
|
||||
}
|
||||
render.NoContent(w, r)
|
||||
}
|
@ -71,6 +71,7 @@ func Start(addr string, secret string) {
|
||||
r.Mount("/rules", ruleRouter())
|
||||
r.Mount("/connections", connectionRouter())
|
||||
r.Mount("/providers/proxies", proxyProviderRouter())
|
||||
r.Mount("/cache", cacheRouter())
|
||||
})
|
||||
|
||||
if uiPath != "" {
|
||||
@ -130,7 +131,7 @@ func authentication(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
func hello(w http.ResponseWriter, r *http.Request) {
|
||||
render.JSON(w, r, render.M{"hello": "clash"})
|
||||
render.JSON(w, r, render.M{"hello": "clash with tun"})
|
||||
}
|
||||
|
||||
func traffic(w http.ResponseWriter, r *http.Request) {
|
||||
|
Reference in New Issue
Block a user