mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
log: add detail of conn
This commit is contained in:
parent
fa274c2c40
commit
705e08a277
@ -56,6 +56,9 @@ func newContext(respWriter http.ResponseWriter, req *http.Request) *UserConnCont
|
||||
ConnID: utils.Md5(req.RemoteAddr + "_" + strconv.Itoa(int(utils.GetCurrentTimestampByMill()))),
|
||||
}
|
||||
}
|
||||
func (c *UserConnContext) GetRemoteAddr() string {
|
||||
return c.RemoteAddr
|
||||
}
|
||||
func (c *UserConnContext) Query(key string) (string, bool) {
|
||||
var value string
|
||||
if value = c.Req.URL.Query().Get(key); value == "" {
|
||||
|
@ -132,7 +132,7 @@ func (ws *WsServer) registerClient(client *Client) {
|
||||
if clientOK { //已经有同平台的连接存在
|
||||
ws.clients.Set(client.userID, client)
|
||||
ws.multiTerminalLoginChecker(cli)
|
||||
log.ZInfo(client.ctx, "repeat login", "userID", client.userID, "platformID", client.platformID)
|
||||
log.ZInfo(client.ctx, "repeat login", "userID", client.userID, "platformID", client.platformID, "old remote addr", getRemoteAdders(cli))
|
||||
atomic.AddInt64(&ws.onlineUserConnNum, 1)
|
||||
} else {
|
||||
ws.clients.Set(client.userID, client)
|
||||
@ -141,6 +141,17 @@ func (ws *WsServer) registerClient(client *Client) {
|
||||
}
|
||||
log.ZInfo(client.ctx, "user online", "online user Num", ws.onlineUserNum, "online user conn Num", ws.onlineUserConnNum)
|
||||
}
|
||||
func getRemoteAdders(client []*Client) string {
|
||||
var ret string
|
||||
for i, c := range client {
|
||||
if i == 0 {
|
||||
ret = c.ctx.GetRemoteAddr()
|
||||
} else {
|
||||
ret += "@" + c.ctx.GetRemoteAddr()
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (ws *WsServer) multiTerminalLoginChecker(client []*Client) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user