Block duplicated IP for guests configurable
This commit is contained in:
@@ -311,6 +311,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
|
configList.push_back(ConfigInfo("DBServerDatabaseName", CONFIG_TYPE_STRING, "pokerth"));
|
||||||
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("DBServerEncryptionKey", CONFIG_TYPE_STRING, ""));
|
||||||
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
configList.push_back(ConfigInfo("GameNameBadWordList", CONFIG_TYPE_STRING_LIST, "Regex"));
|
||||||
|
configList.push_back(ConfigInfo("ServerBlockGuestDuplicateIP", CONFIG_TYPE_INT, "0"));
|
||||||
|
|
||||||
//fill tempList firstTime
|
//fill tempList firstTime
|
||||||
configBufferList = configList;
|
configBufferList = configList;
|
||||||
|
|||||||
@@ -1062,7 +1062,7 @@ ServerLobbyThread::HandleNetPacketInit(boost::shared_ptr<SessionData> session, c
|
|||||||
}
|
}
|
||||||
// check if a guest session in lobby with same ip is already connected and
|
// check if a guest session in lobby with same ip is already connected and
|
||||||
// if number of lobby guests >= SERVER_MAX_GUEST_USERS_LOBBY
|
// if number of lobby guests >= SERVER_MAX_GUEST_USERS_LOBBY
|
||||||
if(!m_sessionManager.IsGuestAllowedToConnect(session->GetClientAddr())) {
|
if(!m_sessionManager.IsGuestAllowedToConnect(session->GetClientAddr(), m_serverConfig.readConfigInt("ServerBlockGuestDuplicateIP"))) {
|
||||||
SessionError(session, ERR_NET_SERVER_FULL);
|
SessionError(session, ERR_NET_SERVER_FULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ SessionManager::IsClientAddressConnected(const std::string &clientAddress) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SessionManager::IsGuestAllowedToConnect(const std::string &clientAddress) const
|
SessionManager::IsGuestAllowedToConnect(const std::string &clientAddress, int blockDup) const
|
||||||
{
|
{
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
|
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
|
||||||
@@ -262,7 +262,7 @@ SessionManager::IsGuestAllowedToConnect(const std::string &clientAddress) const
|
|||||||
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
|
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
|
||||||
if (tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST) {
|
if (tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST) {
|
||||||
num++;
|
num++;
|
||||||
if (i->second->GetClientAddr() == clientAddress) {
|
if (blockDup && i->second->GetClientAddr() == clientAddress) {
|
||||||
// guest has same ip as another guest in lobby or
|
// guest has same ip as another guest in lobby or
|
||||||
retVal = false;
|
retVal = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
bool IsPlayerConnected(const std::string &playerName) const;
|
bool IsPlayerConnected(const std::string &playerName) const;
|
||||||
bool IsPlayerConnected(unsigned uniqueId) const;
|
bool IsPlayerConnected(unsigned uniqueId) const;
|
||||||
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
bool IsClientAddressConnected(const std::string &clientAddress) const;
|
||||||
bool IsGuestAllowedToConnect(const std::string &clientAddress) const;
|
bool IsGuestAllowedToConnect(const std::string &clientAddress, int) const;
|
||||||
|
|
||||||
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
void ForEach(boost::function<void (boost::shared_ptr<SessionData>)> func);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user