mirror of
https://github.com/lwch/natpass
synced 2025-10-06 13:57:16 +08:00
修正server端的connect_req和connect_rep消息没有保持同一条通路的问题
This commit is contained in:
@@ -159,22 +159,20 @@ func (h *Handler) msgHook(msg *network.Msg, toCli *client) {
|
||||
fromCli := h.clients[from]
|
||||
h.RUnlock()
|
||||
switch msg.GetXType() {
|
||||
case network.Msg_connect_rep:
|
||||
if msg.GetCrep().GetOk() {
|
||||
id := msg.GetCrep().GetId()
|
||||
var pair [2]*client
|
||||
if fromCli != nil {
|
||||
fromCli.addLink(id)
|
||||
pair[0] = fromCli
|
||||
}
|
||||
if toCli != nil {
|
||||
toCli.addLink(id)
|
||||
pair[1] = toCli
|
||||
}
|
||||
h.Lock()
|
||||
h.links[id] = pair
|
||||
h.Unlock()
|
||||
case network.Msg_connect_req:
|
||||
id := msg.GetCrep().GetId()
|
||||
var pair [2]*client
|
||||
if fromCli != nil {
|
||||
fromCli.addLink(id)
|
||||
pair[0] = fromCli
|
||||
}
|
||||
if toCli != nil {
|
||||
toCli.addLink(id)
|
||||
pair[1] = toCli
|
||||
}
|
||||
h.Lock()
|
||||
h.links[id] = pair
|
||||
h.Unlock()
|
||||
case network.Msg_disconnect:
|
||||
if fromCli != nil {
|
||||
fromCli.removeLink(msg.GetXDisconnect().GetId())
|
||||
|
Reference in New Issue
Block a user