mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[fix] 客户端map错误
This commit is contained in:
@@ -87,7 +87,7 @@ func (s *HookGrpcService) OnClientConnected(ctx context.Context, in *exhook2.Cli
|
||||
return nil, err
|
||||
}
|
||||
//添加连接ID
|
||||
mqttclient.MqttClient[etoken.DeviceId] = in.Clientinfo.Clientid
|
||||
mqttclient.MqttClient.Store(etoken.DeviceId, in.Clientinfo.Clientid)
|
||||
data := netbase.CreateConnectionInfo(message.ConnectMes, "mqtt", in.Clientinfo.Clientid, in.Clientinfo.Peerhost, etoken)
|
||||
s.HookService.MessageCh <- data
|
||||
return &exhook2.EmptySuccess{}, nil
|
||||
@@ -102,7 +102,7 @@ func (s *HookGrpcService) OnClientDisconnected(ctx context.Context, in *exhook2.
|
||||
return nil, err
|
||||
}
|
||||
//删除连接ID
|
||||
delete(mqttclient.MqttClient, etoken.DeviceId)
|
||||
mqttclient.MqttClient.Delete(etoken.DeviceId)
|
||||
data := netbase.CreateConnectionInfo(message.DisConnectMes, "mqtt", in.Clientinfo.Clientid, in.Clientinfo.Peerhost, etoken)
|
||||
s.HookService.MessageCh <- data
|
||||
return &exhook2.EmptySuccess{}, nil
|
||||
|
||||
@@ -60,7 +60,7 @@ func (hhs *HookTcpService) hook() {
|
||||
data := netbase.CreateConnectionInfo(message.DisConnectMes, "tcp", hhs.conn.RemoteAddr().String(), hhs.conn.RemoteAddr().String(), etoken)
|
||||
hhs.HookService.MessageCh <- data
|
||||
}
|
||||
delete(tcpclient.TcpClient, etoken.DeviceId)
|
||||
tcpclient.TcpClient.Delete(etoken.DeviceId)
|
||||
isAuth = false
|
||||
return
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func (hhs *HookTcpService) hook() {
|
||||
data := netbase.CreateConnectionInfo(message.ConnectMes, "tcp", hhs.conn.RemoteAddr().String(), hhs.conn.RemoteAddr().String(), etoken)
|
||||
hhs.HookService.MessageCh <- data
|
||||
isAuth = true
|
||||
tcpclient.TcpClient[etoken.DeviceId] = hhs.conn
|
||||
tcpclient.TcpClient.Store(etoken.DeviceId, hhs.conn)
|
||||
hhs.Send("success")
|
||||
} else {
|
||||
hhs.Send("fail")
|
||||
|
||||
@@ -45,7 +45,7 @@ func InitUdpHook(addr string, hs *hook_message_work.HookService) {
|
||||
data := netbase.CreateConnectionInfo(message.DisConnectMes, "udp", client.IP.String(), client.AddrPort().String(), etoken)
|
||||
hhs.HookService.MessageCh <- data
|
||||
}
|
||||
delete(udpclient.UdpClient, etoken.DeviceId)
|
||||
udpclient.UdpClient.Delete(etoken.DeviceId)
|
||||
delete(authMap, client.AddrPort().String())
|
||||
continue
|
||||
}
|
||||
@@ -73,10 +73,10 @@ func InitUdpHook(addr string, hs *hook_message_work.HookService) {
|
||||
data := netbase.CreateConnectionInfo(message.ConnectMes, "udp", client.IP.String(), client.AddrPort().String(), etoken)
|
||||
hhs.HookService.MessageCh <- data
|
||||
authMap[client.AddrPort().String()] = true
|
||||
udpclient.UdpClient[etoken.DeviceId] = &udpclient.UdpClientT{
|
||||
udpclient.UdpClient.Store(etoken.DeviceId, &udpclient.UdpClientT{
|
||||
Conn: server.listener,
|
||||
Addr: client,
|
||||
}
|
||||
})
|
||||
hhs.Send(client, "success")
|
||||
} else {
|
||||
hhs.Send(client, "fail")
|
||||
|
||||
Reference in New Issue
Block a user