Save server config when exit server lobby
This commit is contained in:
parent
c778a22a3a
commit
8ad3cbdff9
@ -2375,6 +2375,7 @@ void runUnitTests()
|
|||||||
Log::info("UnitTest", "IP ban");
|
Log::info("UnitTest", "IP ban");
|
||||||
NetworkConfig::get()->unsetNetworking();
|
NetworkConfig::get()->unsetNetworking();
|
||||||
ServerLobby sl;
|
ServerLobby sl;
|
||||||
|
sl.setSaveServerConfig(false);
|
||||||
|
|
||||||
ServerConfig::m_server_ip_ban_list =
|
ServerConfig::m_server_ip_ban_list =
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,7 @@ ServerLobby::ServerLobby() : LobbyProtocol(NULL)
|
|||||||
m_has_created_server_id_file = false;
|
m_has_created_server_id_file = false;
|
||||||
setHandleDisconnections(true);
|
setHandleDisconnections(true);
|
||||||
m_state = SET_PUBLIC_ADDRESS;
|
m_state = SET_PUBLIC_ADDRESS;
|
||||||
|
m_save_server_config = true;
|
||||||
updateBanList();
|
updateBanList();
|
||||||
if (ServerConfig::m_ranked)
|
if (ServerConfig::m_ranked)
|
||||||
{
|
{
|
||||||
@ -121,6 +122,8 @@ ServerLobby::~ServerLobby()
|
|||||||
unregisterServer(true/*now*/);
|
unregisterServer(true/*now*/);
|
||||||
}
|
}
|
||||||
delete m_result_ns;
|
delete m_result_ns;
|
||||||
|
if (m_save_server_config)
|
||||||
|
ServerConfig::writeServerConfigToDisk();
|
||||||
} // ~ServerLobby
|
} // ~ServerLobby
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -2047,6 +2050,8 @@ void ServerLobby::updateBanList()
|
|||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
ServerConfig::m_server_ip_ban_list = final_ip_ban_list;
|
ServerConfig::m_server_ip_ban_list = final_ip_ban_list;
|
||||||
|
// Default guided entry
|
||||||
|
ServerConfig::m_server_ip_ban_list["0.0.0.0/0"] = 0;
|
||||||
|
|
||||||
std::map<uint32_t, uint32_t> final_online_id_ban_list;
|
std::map<uint32_t, uint32_t> final_online_id_ban_list;
|
||||||
for (auto& ban : ServerConfig::m_server_online_id_ban_list)
|
for (auto& ban : ServerConfig::m_server_online_id_ban_list)
|
||||||
@ -2059,6 +2064,7 @@ void ServerLobby::updateBanList()
|
|||||||
ServerConfig::m_server_online_id_ban_list.at(ban.first);
|
ServerConfig::m_server_online_id_ban_list.at(ban.first);
|
||||||
}
|
}
|
||||||
ServerConfig::m_server_online_id_ban_list = final_online_id_ban_list;
|
ServerConfig::m_server_online_id_ban_list = final_online_id_ban_list;
|
||||||
|
ServerConfig::m_server_online_id_ban_list[0] = 0;
|
||||||
} // updateBanList
|
} // updateBanList
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -152,6 +152,8 @@ private:
|
|||||||
|
|
||||||
bool m_registered_for_once_only;
|
bool m_registered_for_once_only;
|
||||||
|
|
||||||
|
bool m_save_server_config;
|
||||||
|
|
||||||
// connection management
|
// connection management
|
||||||
void clientDisconnected(Event* event);
|
void clientDisconnected(Event* event);
|
||||||
void connectionRequested(Event* event);
|
void connectionRequested(Event* event);
|
||||||
@ -272,7 +274,7 @@ public:
|
|||||||
virtual bool isRacing() const OVERRIDE { return m_state.load() == RACING; }
|
virtual bool isRacing() const OVERRIDE { return m_state.load() == RACING; }
|
||||||
bool isBannedForIP(const TransportAddress& addr) const;
|
bool isBannedForIP(const TransportAddress& addr) const;
|
||||||
bool allowJoinedPlayersWaiting() const;
|
bool allowJoinedPlayersWaiting() const;
|
||||||
|
void setSaveServerConfig(bool val) { m_save_server_config = val; }
|
||||||
}; // class ServerLobby
|
}; // class ServerLobby
|
||||||
|
|
||||||
#endif // SERVER_LOBBY_HPP
|
#endif // SERVER_LOBBY_HPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user