Stats callbacks

This commit is contained in:
9seconds
2018-07-09 11:44:42 +03:00
parent 045d417ece
commit 1aa8cfe036
3 changed files with 14 additions and 4 deletions
+5
View File
@@ -12,6 +12,7 @@ import (
"github.com/9seconds/mtg/client"
"github.com/9seconds/mtg/config"
"github.com/9seconds/mtg/mtproto"
"github.com/9seconds/mtg/stats"
"github.com/9seconds/mtg/telegram"
"github.com/9seconds/mtg/wrappers"
)
@@ -45,6 +46,7 @@ func (p *Proxy) accept(conn net.Conn) {
conn.Close()
if err := recover(); err != nil {
stats.NewCrash()
log.Errorw("Crash of accept handler", "error", err)
}
}()
@@ -58,6 +60,9 @@ func (p *Proxy) accept(conn net.Conn) {
}
defer client.(io.Closer).Close()
stats.ClientConnected(opts.ConnectionType, client.RemoteAddr())
defer stats.ClientDisconnected(opts.ConnectionType, client.RemoteAddr())
server, err := p.getTelegramConn(opts, connID)
if err != nil {
log.Errorw("Cannot initialize server connection", "error", err)