StunClient code cleanup: use enet functions, endianness

Instead of using platform-specific sockets, use enet_socket* functions
(which ends up doing the same).
Clean up some confusing APIs, removing the distinction between finding
the public IP for the host/join.

Fix endianness support & use simpler code.

Refs D364 / 61261d14fc (and some subsequent fixing diffs).

Differential Revision: https://code.wildfiregames.com/D3970
This was SVN commit r25453.
This commit is contained in:
wraitii
2021-05-17 15:14:10 +00:00
parent f1467d10fd
commit 895e4e6aa6
12 changed files with 187 additions and 244 deletions
+11 -2
View File
@@ -1658,11 +1658,20 @@ u16 CNetServer::GetLocalPort() const
return m_Worker->m_Host->address.port;
}
void CNetServer::SetConnectionData(const CStr& ip, const u16 port, bool useSTUN)
void CNetServer::SetConnectionData(const CStr& ip, const u16 port)
{
m_PublicIp = ip;
m_PublicPort = port;
m_UseSTUN = useSTUN;
m_UseSTUN = false;
}
bool CNetServer::SetConnectionDataViaSTUN()
{
m_UseSTUN = true;
std::lock_guard<std::mutex> lock(m_Worker->m_WorkerMutex);
if (!m_Worker->m_Host)
return false;
return StunClient::FindPublicIP(*m_Worker->m_Host, m_PublicIp, m_PublicPort);
}
bool CNetServer::CheckPasswordAndIncrement(const CStr& password, const std::string& username)