mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-16 05:40:43 +08:00
update stats
This commit is contained in:
@@ -5,6 +5,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
|
||||||
|
"github.com/xjasonlyu/tun2socks/common/log"
|
||||||
"github.com/xjasonlyu/tun2socks/common/stats/session"
|
"github.com/xjasonlyu/tun2socks/common/stats/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,7 +20,9 @@ func init() {
|
|||||||
session.StatsVersion = version
|
session.StatsVersion = version
|
||||||
|
|
||||||
sessionStater = session.NewSimpleSessionStater()
|
sessionStater = session.NewSimpleSessionStater()
|
||||||
sessionStater.Start()
|
if err := sessionStater.Start(); err != nil {
|
||||||
|
log.Fatalf("start session stater failed: %v", err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sessionStater = nil
|
sessionStater = nil
|
||||||
}
|
}
|
||||||
|
@@ -97,8 +97,7 @@ func (s *simpleSessionStater) Start() error {
|
|||||||
})
|
})
|
||||||
mux.HandleFunc(StatsPath, sessionStatsHandler)
|
mux.HandleFunc(StatsPath, sessionStatsHandler)
|
||||||
s.server = &http.Server{Addr: StatsAddr, Handler: mux}
|
s.server = &http.Server{Addr: StatsAddr, Handler: mux}
|
||||||
go s.server.ListenAndServe()
|
return s.server.ListenAndServe()
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *simpleSessionStater) Stop() error {
|
func (s *simpleSessionStater) Stop() error {
|
||||||
|
Reference in New Issue
Block a user