mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 15:44:01 +03:00
Stats callbacks
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user