可以完成内网连接,外网打洞失败

This commit is contained in:
2025-10-14 21:44:40 +08:00
parent f0155d1e63
commit e5e8c1c19f
3 changed files with 158 additions and 32 deletions

View File

@@ -217,7 +217,7 @@ func (s *sP2P) handleDiscover(conn *websocket.Conn, msg GatewayMessage) {
fromClient.LastActive = time.Now()
s.lock.Unlock()
if targetClient != nil {
if targetClient == nil {
// 目标不存在
s.sendMessage(conn, GatewayMessage{
Type: MsgTypeDiscoverAck,
@@ -237,10 +237,10 @@ func (s *sP2P) handleDiscover(conn *websocket.Conn, msg GatewayMessage) {
From: "gateway", // 发送方是网关
To: msg.From, // 接收方是原请求方
Data: gjson.MustEncode(g.Map{
"found": true,
"peer_id": targetClient.PeerID,
//"addrs": s.getAddrsJSON(targetClient.Addrs),
"addrs": targetClient.Addrs,
"found": true,
"peer_id": targetClient.PeerID,
"addrs": targetClient.Addrs,
"target_id": data.TargetID,
}),
})