Add addr in broekr log (#146)

This commit is contained in:
ZhangJian He
2022-04-04 20:41:33 +08:00
committed by GitHub
parent a501565bab
commit a85e9904c2
+3 -2
View File
@@ -283,7 +283,7 @@ func (b *Broker) handleConnection(typ int, conn net.Conn) {
return return
} }
log.Info("read connect from ", zap.String("clientID", msg.ClientIdentifier)) log.Info("read connect from ", zap.String("clientID", msg.ClientIdentifier), zap.String("addr", conn.RemoteAddr().String()))
connack := packets.NewControlPacket(packets.Connack).(*packets.ConnackPacket) connack := packets.NewControlPacket(packets.Connack).(*packets.ConnackPacket)
connack.SessionPresent = msg.CleanSession connack.SessionPresent = msg.CleanSession
@@ -360,7 +360,8 @@ func (b *Broker) handleConnection(typ int, conn net.Conn) {
case CLIENT: case CLIENT:
old, exist = b.clients.Load(cid) old, exist = b.clients.Load(cid)
if exist { if exist {
log.Warn("client exist, close old...", zap.String("clientID", c.info.clientID)) log.Warn("client exist, close old...", zap.String("clientID", c.info.clientID),
zap.String("addr", conn.RemoteAddr().String()))
ol, ok := old.(*client) ol, ok := old.(*client)
if ok { if ok {
ol.Close() ol.Close()