Index: ps/trunk/source/lobby/StanzaExtensions.cpp =================================================================== --- ps/trunk/source/lobby/StanzaExtensions.cpp +++ ps/trunk/source/lobby/StanzaExtensions.cpp @@ -129,7 +129,7 @@ if (!tag || tag->name() != "query" || tag->xmlns() != XMLNS_GAMELIST) return; - const glooxwrapper::Tag* c = tag->findTag_clone("query/game"); + const glooxwrapper::Tag* c = tag->findTag_clone("query/command"); if (c) m_Command = c->cdata(); glooxwrapper::Tag::free(c); Index: ps/trunk/source/lobby/XmppClient.cpp =================================================================== --- ps/trunk/source/lobby/XmppClient.cpp +++ ps/trunk/source/lobby/XmppClient.cpp @@ -430,8 +430,6 @@ GameListQuery* g = new GameListQuery(); g->m_Command = "register"; glooxwrapper::Tag* game = glooxwrapper::Tag::allocate("game"); - // Add a fake ip which will be overwritten by the ip stamp XMPP module on the server. - game->addAttribute("ip", "fake"); // Iterate through all the properties reported and add them to the stanza. std::vector properties; @@ -861,6 +859,23 @@ } if (gq) { + if (iq.from().full() == m_xpartamuppId && gq->m_Command == "register" && g_NetServer && !g_NetServer->GetUseSTUN()) + { + if (gq->m_GameList.empty()) + { + LOGWARNING("XmppClient: Received empty game list in response to Game Register"); + return true; + } + std::string publicIP = gq->m_GameList.front()->findAttribute("ip").to_string(); + if (publicIP.empty()) + { + LOGWARNING("XmppClient: Received game with no IP in response to Game Register"); + return true; + } + g_NetServer->SetConnectionData(publicIP, g_NetServer->GetPublicPort(), false); + return true; + } + for (const glooxwrapper::Tag* const& t : m_GameList) glooxwrapper::Tag::free(t); m_GameList.clear(); Index: ps/trunk/source/network/StunClient.h =================================================================== --- ps/trunk/source/network/StunClient.h +++ ps/trunk/source/network/StunClient.h @@ -40,8 +40,6 @@ bool FindStunEndpointJoin(ENetHost& transactionHost, StunClient::StunEndpoint& stunEndpoint); void SendHolePunchingMessages(ENetHost& enetClient, const std::string& serverAddress, u16 serverPort); - -bool GetPublicIp(CStr8& ip, u16 port); } #endif // STUNCLIENT_H Index: ps/trunk/source/network/StunClient.cpp =================================================================== --- ps/trunk/source/network/StunClient.cpp +++ ps/trunk/source/network/StunClient.cpp @@ -371,11 +371,6 @@ ParseStunResponse(buffer); } -bool StunClient::GetPublicIp(CStr8& ip, u16 port) -{ - return FindStunEndpointHost(ip, port); -} - bool StunClient::FindStunEndpointHost(CStr8& ip, u16& port) { ENetAddress hostAddr{ENET_HOST_ANY, static_cast(port)}; Index: ps/trunk/source/network/scripting/JSInterface_Network.cpp =================================================================== --- ps/trunk/source/network/scripting/JSInterface_Network.cpp +++ ps/trunk/source/network/scripting/JSInterface_Network.cpp @@ -88,22 +88,15 @@ bool hasLobby = !!g_XmppClient; g_NetServer = new CNetServer(hasLobby); // In lobby, we send our public ip and port on request to the players, who want to connect. - // In both cases we need to ping stun server to get our public ip. If we want to host via stun, - // we need port as well. + // In either case we need to know our public IP. If using STUN, we'll use that, + // otherwise, the lobby's reponse to the game registration stanza will tell us our public IP. if (hasLobby) { CStr ip; if (!useSTUN) - { - if (!StunClient::GetPublicIp(ip, serverPort)) - { - ScriptRequest rq(pCmptPrivate->pScriptInterface); - ScriptException::Raise(rq, "Failed to get public ip."); - SAFE_DELETE(g_NetServer); - return; - } - g_NetServer->SetConnectionData(ip, serverPort, false); - } + // Don't store IP - the lobby bot will send it later. + // (if a client tries to connect before it's setup, they'll be disconnected) + g_NetServer->SetConnectionData("", serverPort, false); else { u16 port = serverPort;