Block bad game names on server.

This commit is contained in:
lotodore
2010-09-05 00:15:25 +00:00
parent 03be7c2f16
commit 7a1a10abf5
8 changed files with 60 additions and 13 deletions
+31 -1
View File
@@ -51,7 +51,7 @@ ServerBanManager::BanPlayerRegex(const string &playerRegex, unsigned durationHou
TimedPlayerBan tmpBan;
tmpBan.timer = InternalRegisterTimedBan(banId, durationHours);
tmpBan.nameRegex = boost::regex(playerRegex, boost::regex_constants::no_except);
tmpBan.nameRegex = boost::regex(playerRegex, boost::regex::extended | boost::regex::icase);
m_banPlayerNameMap[banId] = tmpBan;
}
@@ -186,6 +186,36 @@ ServerBanManager::IsIPAddressBanned(const std::string &ipAddress) const
return retVal;
}
void
ServerBanManager::InitGameNameBadWordList(const std::list<string> &badWordList)
{
list<string>::const_iterator i = badWordList.begin();
list<string>::const_iterator end = badWordList.end();
while (i != end)
{
m_gameNameBadWordFilter.push_back(boost::regex(*i, boost::regex::extended | boost::regex::icase));
++i;
}
}
bool
ServerBanManager::IsBadGameName(const std::string &name) const
{
bool retVal = false;
RegexList::const_iterator i = m_gameNameBadWordFilter.begin();
RegexList::const_iterator end = m_gameNameBadWordFilter.end();
while (i != end)
{
if (regex_match(name, *i))
{
retVal = true;
break;
}
++i;
}
return retVal;
}
boost::shared_ptr<boost::asio::deadline_timer>
ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours)
{