mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
Quit when configured bindaddr cannot be resolved
Quit client and server if the configured bindaddr cannot be resolved. Disable econ if configured bindaddr cannot be resolved. To ensure that the configured bindaddr is not silently ignored.
This commit is contained in:
parent
2c518f2778
commit
85f5e9c5f9
|
@ -3017,16 +3017,16 @@ void CClient::Run()
|
|||
// open socket
|
||||
{
|
||||
NETADDR BindAddr;
|
||||
if(g_Config.m_Bindaddr[0] && net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||
{
|
||||
// got bindaddr
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
}
|
||||
else
|
||||
if(g_Config.m_Bindaddr[0] == '\0')
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
}
|
||||
else if(net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) != 0)
|
||||
{
|
||||
dbg_msg("client", "The configured bindaddr '%s' cannot be resolved", g_Config.m_Bindaddr);
|
||||
return;
|
||||
}
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
for(unsigned int i = 0; i < std::size(m_aNetClient); i++)
|
||||
{
|
||||
int &PortRef = i == CONN_MAIN ? g_Config.m_ClPort : i == CONN_DUMMY ? g_Config.m_ClDummyPort : g_Config.m_ClContactPort;
|
||||
|
|
|
@ -2568,12 +2568,16 @@ int CServer::Run()
|
|||
|
||||
// start server
|
||||
NETADDR BindAddr;
|
||||
int NetType = Config()->m_SvIpv4Only ? NETTYPE_IPV4 : NETTYPE_ALL;
|
||||
|
||||
if(!Config()->m_Bindaddr[0] || net_host_lookup(Config()->m_Bindaddr, &BindAddr, NetType) != 0)
|
||||
if(g_Config.m_Bindaddr[0] == '\0')
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
|
||||
BindAddr.type = NetType;
|
||||
}
|
||||
else if(net_host_lookup(g_Config.m_Bindaddr, &BindAddr, NETTYPE_ALL) != 0)
|
||||
{
|
||||
dbg_msg("server", "The configured bindaddr '%s' cannot be resolved", g_Config.m_Bindaddr);
|
||||
return -1;
|
||||
}
|
||||
BindAddr.type = Config()->m_SvIpv4Only ? NETTYPE_IPV4 : NETTYPE_ALL;
|
||||
|
||||
int Port = Config()->m_SvPort;
|
||||
for(BindAddr.port = Port != 0 ? Port : 8303; !m_NetServer.Open(BindAddr, &m_ServerBan, Config()->m_SvMaxClients, Config()->m_SvMaxClientsPerIP); BindAddr.port++)
|
||||
|
|
|
@ -64,18 +64,18 @@ void CEcon::Init(CConfig *pConfig, IConsole *pConsole, CNetBan *pNetBan)
|
|||
return;
|
||||
|
||||
NETADDR BindAddr;
|
||||
if(g_Config.m_EcBindaddr[0] && net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) == 0)
|
||||
{
|
||||
// got bindaddr
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
BindAddr.port = g_Config.m_EcPort;
|
||||
}
|
||||
else
|
||||
if(g_Config.m_EcBindaddr[0] == '\0')
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
BindAddr.port = g_Config.m_EcPort;
|
||||
}
|
||||
else if(net_host_lookup(g_Config.m_EcBindaddr, &BindAddr, NETTYPE_ALL) != 0)
|
||||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "The configured bindaddr '%s' cannot be resolved.", g_Config.m_Bindaddr);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "econ", aBuf);
|
||||
}
|
||||
BindAddr.type = NETTYPE_ALL;
|
||||
BindAddr.port = g_Config.m_EcPort;
|
||||
|
||||
if(m_NetConsole.Open(BindAddr, pNetBan))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue