Feature: more fields in stats version

This commit is contained in:
xjasonlyu
2022-02-09 17:25:55 +08:00
parent 2f21e10be6
commit 283008536b
2 changed files with 19 additions and 1 deletions
+11
View File
@@ -0,0 +1,11 @@
package module
import (
"runtime/debug"
)
// Info returns project dependencies as []*debug.Module.
func Info() []*debug.Module {
bi, _ := debug.ReadBuildInfo()
return bi.Deps
}
+8 -1
View File
@@ -8,6 +8,8 @@ import (
"strings"
"time"
"github.com/xjasonlyu/tun2socks/v2/internal/debug"
"github.com/xjasonlyu/tun2socks/v2/internal/module"
"github.com/xjasonlyu/tun2socks/v2/log"
"github.com/xjasonlyu/tun2socks/v2/tunnel/statistic"
V "github.com/xjasonlyu/tun2socks/v2/version"
@@ -212,5 +214,10 @@ func traffic(w http.ResponseWriter, r *http.Request) {
}
func version(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, render.M{"version": V.Version, "commit": V.GitCommit})
render.JSON(w, r, render.M{
"version": V.Version,
"commit": V.GitCommit,
"debug": debug.Debug(),
"modules": module.Info(),
})
}