RCON socket bind improvement

Check 'net_usesocketsforloopback' before binding sockets; allows binding to loopback as well.
This commit is contained in:
Kawe Mazidjatari 2023-04-30 11:32:51 +02:00
parent 90cf742fb5
commit f97cf6c249
2 changed files with 9 additions and 1 deletions

View File

@ -53,8 +53,15 @@ void CRConServer::Init(void)
return;
}
}
else
{
// Already initialized.
return;
}
m_Address.SetFromString(Format("[%s]:%i", NET_IPV6_UNSPEC, hostport->GetInt()).c_str(), true);
const char* pszAddress = net_usesocketsforloopback->GetBool() ? NET_IPV6_UNSPEC : NET_IPV6_LOOPBACK;
m_Address.SetFromString(Format("[%s]:%i", pszAddress, hostport->GetInt()).c_str(), true);
m_Socket.CreateListenSocket(m_Address);
DevMsg(eDLL_T::SERVER, "Remote server access initialized ('%s')\n", m_Address.ToString());

View File

@ -3,6 +3,7 @@
#define NET_IPV4_UNSPEC "0.0.0.0"
#define NET_IPV6_UNSPEC "::"
#define NET_IPV6_LOOPBACK "::1"
enum class netadrtype_t
{