Implement a workaround for routers without NAT loopback.

This allows joining a lobby game hosted on the same network (behind the
same NAT gateway).
This is relatively primitive to keep things simple: if the server and
the client have the same public IP, it is assumed that they are on the
same network and the client instead requests the local IP.

Differential Revision: https://code.wildfiregames.com/D3944
This was SVN commit r25448.
This commit is contained in:
wraitii
2021-05-16 15:34:38 +00:00
parent a19dc1717f
commit 2034136560
13 changed files with 170 additions and 15 deletions
+10 -2
View File
@@ -1640,14 +1640,22 @@ bool CNetServer::SetupConnection(const u16 port)
return m_Worker->SetupConnection(port);
}
CStr CNetServer::GetPublicIp() const
{
return m_PublicIp;
}
u16 CNetServer::GetPublicPort() const
{
return m_PublicPort;
}
CStr CNetServer::GetPublicIp() const
u16 CNetServer::GetLocalPort() const
{
return m_PublicIp;
std::lock_guard<std::mutex> lock(m_Worker->m_WorkerMutex);
if (!m_Worker->m_Host)
return 0;
return m_Worker->m_Host->address.port;
}
void CNetServer::SetConnectionData(const CStr& ip, const u16 port, bool useSTUN)