diff --git a/cmd/tun2socks/main_stats.go b/cmd/tun2socks/main_stats.go index 9d3ae9e..7fe45a4 100644 --- a/cmd/tun2socks/main_stats.go +++ b/cmd/tun2socks/main_stats.go @@ -12,9 +12,11 @@ func init() { args.Stats = flag.Bool("stats", false, "Enable statistics") args.StatsAddr = flag.String("statsAddr", "localhost:6001", "listen address of stats, open in your browser to view statistics") + session.StatsAddr = *args.StatsAddr + session.StatsVersion = version + addPostFlagsInitFn(func() { if *args.Stats { - session.StatsAddr = *args.StatsAddr sessionStater = session.NewSimpleSessionStater() sessionStater.Start() } else { diff --git a/common/stats/session/session.go b/common/stats/session/session.go index 366eea9..a585700 100644 --- a/common/stats/session/session.go +++ b/common/stats/session/session.go @@ -22,6 +22,8 @@ const maxCompletedSessions = 100 var ( StatsAddr = "localhost:6001" StatsPath = "/stats/session/plain" + + StatsVersion = "" ) type simpleSessionStater struct { @@ -79,7 +81,7 @@ func (s *simpleSessionStater) Start() error { border-collapse: collapse; text-align: right; padding: 4; -}Go-tun2socks Sessions`) +}Go-tun2socks %s`, StatsVersion) _, _ = fmt.Fprintf(w, "

%s

", now()) _, _ = fmt.Fprintf(w, "

Uptime: %s

", uptime()) _, _ = fmt.Fprintf(w, "

Active sessions %d

", len(sessions))