mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
switch, limited tries & sv_port 0
This commit is contained in:
parent
6a87278c3d
commit
beaadca6a9
|
@ -13,8 +13,12 @@
|
|||
# ---------------
|
||||
|
||||
# Server port (only port range 8303-8310 show up in LAN tab)
|
||||
# - "Automatically selecting free port from range 8303-8310" for 0
|
||||
sv_port 8303
|
||||
|
||||
# Find free port automatically (range from 8303-8310)
|
||||
sv_find_free_port 1
|
||||
|
||||
# Server name
|
||||
sv_name "My DDNet server"
|
||||
|
||||
|
|
|
@ -2322,24 +2322,49 @@ int CServer::Run()
|
|||
{
|
||||
// sweet!
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort;
|
||||
BindAddr.port = g_Config.m_SvPort == 0 ? 8303 : g_Config.m_SvPort;
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_zero(&BindAddr, sizeof(BindAddr));
|
||||
BindAddr.type = NetType;
|
||||
BindAddr.port = g_Config.m_SvPort;
|
||||
BindAddr.port = g_Config.m_SvPort == 0 ? 8303 : g_Config.m_SvPort;
|
||||
}
|
||||
|
||||
#if defined(CONF_UPNP)
|
||||
m_UPnP.Open(BindAddr);
|
||||
#endif
|
||||
|
||||
if(!g_Config.m_SvFindFreePort && (g_Config.m_SvPort != 0))
|
||||
{
|
||||
if (!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", g_Config.m_SvPort);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!m_NetServer.Open(BindAddr, &m_ServerBan, g_Config.m_SvMaxClients, g_Config.m_SvMaxClientsPerIP, 0))
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", BindAddr.port);
|
||||
if (((int)(BindAddr.port - 8303)) < 7) //ugly af
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use. checking for next port.", BindAddr.port);
|
||||
BindAddr.port++;
|
||||
}
|
||||
else if (g_Config.m_SvFindFreePortM)
|
||||
{
|
||||
dbg_msg("server", "couldn't open socket. port %d might already be in use", BindAddr.port);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Do one more cycle to be sure all ports used
|
||||
g_Config.m_SvFindFreePortM = 1;
|
||||
BindAddr.port = 8303;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_NetServer.SetCallbacks(NewClientCallback, NewClientNoAuthCallback, ClientRejoinCallback, DelClientCallback, this);
|
||||
|
||||
|
|
|
@ -140,6 +140,8 @@ MACRO_CONFIG_STR(SvDnsblKey, sv_dnsbl_key, 128, "", CFGFLAG_SERVER|CFGFLAG_NONTE
|
|||
MACRO_CONFIG_INT(SvDnsblVote, sv_dnsbl_vote, 0, 0, 1, CFGFLAG_SERVER, "Block votes by blacklisted addresses")
|
||||
MACRO_CONFIG_INT(SvDnsblBan, sv_dnsbl_ban, 0, 0, 1, CFGFLAG_SERVER, "Automatically ban blacklisted addresses")
|
||||
MACRO_CONFIG_INT(SvRconVote, sv_rcon_vote, 0, 0, 1, CFGFLAG_SERVER, "Only allow authed clients to call votes")
|
||||
MACRO_CONFIG_INT(SvFindFreePort, sv_find_free_port, 1, 0, 1, CFGFLAG_SERVER, "Enables automatically searching for next available port (8303-8310)")
|
||||
MACRO_CONFIG_INT(SvFindFreePortM, sv_find_free_port_m, 0, 0, 1, CFGFLAG_SERVER, "")
|
||||
|
||||
MACRO_CONFIG_INT(SvPlayerDemoRecord, sv_player_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos for each player")
|
||||
MACRO_CONFIG_INT(SvDemoChat, sv_demo_chat, 0, 0, 1, CFGFLAG_SERVER, "Record chat for demos")
|
||||
|
|
Loading…
Reference in a new issue