mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-15 13:20:45 +08:00
add stats version
This commit is contained in:
@@ -12,9 +12,11 @@ func init() {
|
|||||||
args.Stats = flag.Bool("stats", false, "Enable statistics")
|
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")
|
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() {
|
addPostFlagsInitFn(func() {
|
||||||
if *args.Stats {
|
if *args.Stats {
|
||||||
session.StatsAddr = *args.StatsAddr
|
|
||||||
sessionStater = session.NewSimpleSessionStater()
|
sessionStater = session.NewSimpleSessionStater()
|
||||||
sessionStater.Start()
|
sessionStater.Start()
|
||||||
} else {
|
} else {
|
||||||
|
@@ -22,6 +22,8 @@ const maxCompletedSessions = 100
|
|||||||
var (
|
var (
|
||||||
StatsAddr = "localhost:6001"
|
StatsAddr = "localhost:6001"
|
||||||
StatsPath = "/stats/session/plain"
|
StatsPath = "/stats/session/plain"
|
||||||
|
|
||||||
|
StatsVersion = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
type simpleSessionStater struct {
|
type simpleSessionStater struct {
|
||||||
@@ -79,7 +81,7 @@ func (s *simpleSessionStater) Start() error {
|
|||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding: 4;
|
padding: 4;
|
||||||
}</style><title>Go-tun2socks Sessions</title></head>`)
|
}</style><title>Go-tun2socks %s</title></head>`, StatsVersion)
|
||||||
_, _ = fmt.Fprintf(w, "<h2>%s</h2>", now())
|
_, _ = fmt.Fprintf(w, "<h2>%s</h2>", now())
|
||||||
_, _ = fmt.Fprintf(w, "<h3>Uptime: %s</h3>", uptime())
|
_, _ = fmt.Fprintf(w, "<h3>Uptime: %s</h3>", uptime())
|
||||||
_, _ = fmt.Fprintf(w, "<p>Active sessions %d</p>", len(sessions))
|
_, _ = fmt.Fprintf(w, "<p>Active sessions %d</p>", len(sessions))
|
||||||
|
Reference in New Issue
Block a user