|
@@ -4,6 +4,7 @@ import (
|
|
"bytes"
|
|
"bytes"
|
|
"net"
|
|
"net"
|
|
"net/http"
|
|
"net/http"
|
|
|
|
+ "runtime/debug"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/sagernet/sing-box/experimental/clashapi/trafficontrol"
|
|
"github.com/sagernet/sing-box/experimental/clashapi/trafficontrol"
|
|
@@ -12,14 +13,23 @@ import (
|
|
"github.com/sagernet/ws/wsutil"
|
|
"github.com/sagernet/ws/wsutil"
|
|
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
+ "github.com/go-chi/chi/v5/middleware"
|
|
"github.com/go-chi/render"
|
|
"github.com/go-chi/render"
|
|
)
|
|
)
|
|
|
|
|
|
// API created by Clash.Meta
|
|
// API created by Clash.Meta
|
|
|
|
|
|
func (s *Server) setupMetaAPI(r chi.Router) {
|
|
func (s *Server) setupMetaAPI(r chi.Router) {
|
|
|
|
+ if s.logDebug {
|
|
|
|
+ r := chi.NewRouter()
|
|
|
|
+ r.Put("/gc", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+ debug.FreeOSMemory()
|
|
|
|
+ })
|
|
|
|
+ r.Mount("/", middleware.Profiler())
|
|
|
|
+ }
|
|
r.Get("/memory", memory(s.trafficManager))
|
|
r.Get("/memory", memory(s.trafficManager))
|
|
r.Mount("/group", groupRouter(s))
|
|
r.Mount("/group", groupRouter(s))
|
|
|
|
+ r.Mount("/upgrade", upgradeRouter(s))
|
|
}
|
|
}
|
|
|
|
|
|
type Memory struct {
|
|
type Memory struct {
|