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");
|
||||
NetworkConfig::get()->unsetNetworking();
|
||||
ServerLobby sl;
|
||||
sl.setSaveServerConfig(false);
|
||||
|
||||
ServerConfig::m_server_ip_ban_list =
|
||||
{
|
||||
|
@ -97,6 +97,7 @@ ServerLobby::ServerLobby() : LobbyProtocol(NULL)
|
||||
m_has_created_server_id_file = false;
|
||||
setHandleDisconnections(true);
|
||||
m_state = SET_PUBLIC_ADDRESS;
|
||||
m_save_server_config = true;
|
||||
updateBanList();
|
||||
if (ServerConfig::m_ranked)
|
||||
{
|
||||
@ -121,6 +122,8 @@ ServerLobby::~ServerLobby()
|
||||
unregisterServer(true/*now*/);
|
||||
}
|
||||
delete m_result_ns;
|
||||
if (m_save_server_config)
|
||||
ServerConfig::writeServerConfigToDisk();
|
||||
} // ~ServerLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2047,6 +2050,8 @@ void ServerLobby::updateBanList()
|
||||
it++;
|
||||
}
|
||||
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;
|
||||
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 = final_online_id_ban_list;
|
||||
ServerConfig::m_server_online_id_ban_list[0] = 0;
|
||||
} // updateBanList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -152,6 +152,8 @@ private:
|
||||
|
||||
bool m_registered_for_once_only;
|
||||
|
||||
bool m_save_server_config;
|
||||
|
||||
// connection management
|
||||
void clientDisconnected(Event* event);
|
||||
void connectionRequested(Event* event);
|
||||
@ -272,7 +274,7 @@ public:
|
||||
virtual bool isRacing() const OVERRIDE { return m_state.load() == RACING; }
|
||||
bool isBannedForIP(const TransportAddress& addr) const;
|
||||
bool allowJoinedPlayersWaiting() const;
|
||||
|
||||
void setSaveServerConfig(bool val) { m_save_server_config = val; }
|
||||
}; // class ServerLobby
|
||||
|
||||
#endif // SERVER_LOBBY_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user