Block bad game names on server.
This commit is contained in:
+2
-1
@@ -310,7 +310,8 @@ JoinGameFailed ::= SEQUENCE {
|
|||||||
notAllowedAsGuest (5),
|
notAllowedAsGuest (5),
|
||||||
notInvited (6),
|
notInvited (6),
|
||||||
gameNameInUse (7),
|
gameNameInUse (7),
|
||||||
invalidSettings (8)
|
badGameName (8),
|
||||||
|
invalidSettings (9)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
myConfigState = OK;
|
myConfigState = OK;
|
||||||
|
|
||||||
// !!!! Revisionsnummer der Configdefaults !!!!!
|
// !!!! Revisionsnummer der Configdefaults !!!!!
|
||||||
configRev = 85;
|
configRev = 86;
|
||||||
|
|
||||||
//standard defaults
|
//standard defaults
|
||||||
logOnOffDefault = "1";
|
logOnOffDefault = "1";
|
||||||
@@ -280,6 +280,7 @@ ConfigFile::ConfigFile(char *argv0, bool readonly) : noWriteAccess(readonly)
|
|||||||
configList.push_back(ConfigInfo("DBServerPassword", CONFIG_TYPE_STRING, ""));
|
configList.push_back(ConfigInfo("DBServerPassword", CONFIG_TYPE_STRING, ""));
|
||||||
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"));
|
||||||
|
|
||||||
//fill tempList firstTime
|
//fill tempList firstTime
|
||||||
configBufferList = configList;
|
configBufferList = configList;
|
||||||
|
|||||||
@@ -863,6 +863,7 @@ void startWindowImpl::networkNotification(int notificationId)
|
|||||||
QMessageBox::Close); }
|
QMessageBox::Close); }
|
||||||
break;
|
break;
|
||||||
case NTF_NET_JOIN_GAME_NAME_IN_USE:
|
case NTF_NET_JOIN_GAME_NAME_IN_USE:
|
||||||
|
case NTF_NET_JOIN_GAME_BAD_NAME:
|
||||||
{ changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME);
|
{ changeContentDialogImpl dialog(this, myConfig, CHANGE_INET_GAME_NAME);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
if(dialog.result() == QDialog::Accepted) {
|
if(dialog.result() == QDialog::Accepted) {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ ServerBanManager::BanPlayerRegex(const string &playerRegex, unsigned durationHou
|
|||||||
|
|
||||||
TimedPlayerBan tmpBan;
|
TimedPlayerBan tmpBan;
|
||||||
tmpBan.timer = InternalRegisterTimedBan(banId, durationHours);
|
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;
|
m_banPlayerNameMap[banId] = tmpBan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,6 +186,36 @@ ServerBanManager::IsIPAddressBanned(const std::string &ipAddress) const
|
|||||||
return retVal;
|
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>
|
boost::shared_ptr<boost::asio::deadline_timer>
|
||||||
ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours)
|
ServerBanManager::InternalRegisterTimedBan(unsigned timerId, unsigned durationHours)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -145,23 +145,23 @@ static void PerformPlayerAction(ServerGame &server, boost::shared_ptr<PlayerInte
|
|||||||
|
|
||||||
player->setMySet(bet);
|
player->setMySet(bet);
|
||||||
|
|
||||||
// update minimumRaise and lastActionPlayer
|
// update minimumRaise and lastActionPlayer
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case PLAYER_ACTION_BET: {
|
case PLAYER_ACTION_BET: {
|
||||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(bet);
|
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(bet);
|
||||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||||
} break;
|
} break;
|
||||||
case PLAYER_ACTION_RAISE: {
|
case PLAYER_ACTION_RAISE: {
|
||||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
||||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||||
} break;
|
} break;
|
||||||
case PLAYER_ACTION_ALLIN: {
|
case PLAYER_ACTION_ALLIN: {
|
||||||
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise()) {
|
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > curGame.getCurrentHand()->getCurrentBeRo()->getMinimumRaise()) {
|
||||||
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
curGame.getCurrentHand()->getCurrentBeRo()->setMinimumRaise(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet());
|
||||||
}
|
}
|
||||||
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) {
|
if(player->getMySet() - curGame.getCurrentHand()->getCurrentBeRo()->getHighestSet() > 0) {
|
||||||
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
curGame.getCurrentHand()->setLastActionPlayer(player->getMyUniqueID());
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,8 @@ ServerLobbyThread::Init(const string &logDir)
|
|||||||
m_serverConfig->readConfigString("DBServerPassword"),
|
m_serverConfig->readConfigString("DBServerPassword"),
|
||||||
m_serverConfig->readConfigString("DBServerDatabaseName"),
|
m_serverConfig->readConfigString("DBServerDatabaseName"),
|
||||||
m_serverConfig->readConfigString("DBServerEncryptionKey"));
|
m_serverConfig->readConfigString("DBServerEncryptionKey"));
|
||||||
|
|
||||||
|
GetBanManager().InitGameNameBadWordList(m_serverConfig->readConfigStringList("GameNameBadWordList"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1335,6 +1337,10 @@ ServerLobbyThread::HandleNetPacketCreateGame(SessionWrapper session, const std::
|
|||||||
{
|
{
|
||||||
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_NAME_IN_USE);
|
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_NAME_IN_USE);
|
||||||
}
|
}
|
||||||
|
else if (GetBanManager().IsBadGameName(gameName))
|
||||||
|
{
|
||||||
|
SendJoinGameFailed(session.sessionData, gameId, NTF_NET_JOIN_GAME_BAD_NAME);
|
||||||
|
}
|
||||||
else if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
else if (session.playerData->GetRights() == PLAYER_RIGHTS_GUEST
|
||||||
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
&& tmpData.gameType != GAME_TYPE_NORMAL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class ServerBanManager : public boost::enable_shared_from_this<ServerBanManager>
|
class ServerBanManager : public boost::enable_shared_from_this<ServerBanManager>
|
||||||
@@ -44,7 +45,11 @@ public:
|
|||||||
bool IsPlayerBanned(const std::string &name) const;
|
bool IsPlayerBanned(const std::string &name) const;
|
||||||
bool IsIPAddressBanned(const std::string &ipAddress) const;
|
bool IsIPAddressBanned(const std::string &ipAddress) const;
|
||||||
|
|
||||||
|
void InitGameNameBadWordList(const std::list<std::string> &badWordList);
|
||||||
|
bool IsBadGameName(const std::string &name) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct TimedPlayerBan
|
struct TimedPlayerBan
|
||||||
{
|
{
|
||||||
boost::shared_ptr<boost::asio::deadline_timer> timer;
|
boost::shared_ptr<boost::asio::deadline_timer> timer;
|
||||||
@@ -57,18 +62,20 @@ protected:
|
|||||||
std::string ipAddress;
|
std::string ipAddress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::map<unsigned, TimedPlayerBan> RegexMap;
|
||||||
|
typedef std::map<unsigned, TimedIPBan> IPAddressMap;
|
||||||
|
typedef std::list<boost::regex> RegexList;
|
||||||
|
|
||||||
boost::shared_ptr<boost::asio::deadline_timer> InternalRegisterTimedBan(unsigned timerId, unsigned durationHours);
|
boost::shared_ptr<boost::asio::deadline_timer> InternalRegisterTimedBan(unsigned timerId, unsigned durationHours);
|
||||||
void TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::deadline_timer> timer);
|
void TimerRemoveBan(const boost::system::error_code &ec, unsigned banId, boost::shared_ptr<boost::asio::deadline_timer> timer);
|
||||||
|
|
||||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||||
|
|
||||||
typedef std::map<unsigned, TimedPlayerBan> RegexMap;
|
|
||||||
typedef std::map<unsigned, TimedIPBan> IPAddressMap;
|
|
||||||
|
|
||||||
unsigned GetNextBanId();
|
unsigned GetNextBanId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RegexMap m_banPlayerNameMap;
|
RegexMap m_banPlayerNameMap;
|
||||||
|
RegexList m_gameNameBadWordFilter;
|
||||||
IPAddressMap m_banIPAddressMap;
|
IPAddressMap m_banIPAddressMap;
|
||||||
unsigned m_curBanId;
|
unsigned m_curBanId;
|
||||||
mutable boost::mutex m_banMutex;
|
mutable boost::mutex m_banMutex;
|
||||||
|
|||||||
@@ -115,7 +115,8 @@
|
|||||||
#define NTF_NET_JOIN_GUEST_FORBIDDEN 214
|
#define NTF_NET_JOIN_GUEST_FORBIDDEN 214
|
||||||
#define NTF_NET_JOIN_NOT_INVITED 215
|
#define NTF_NET_JOIN_NOT_INVITED 215
|
||||||
#define NTF_NET_JOIN_GAME_NAME_IN_USE 216
|
#define NTF_NET_JOIN_GAME_NAME_IN_USE 216
|
||||||
#define NTF_NET_JOIN_INVALID_SETTINGS 217
|
#define NTF_NET_JOIN_GAME_BAD_NAME 217
|
||||||
|
#define NTF_NET_JOIN_INVALID_SETTINGS 218
|
||||||
|
|
||||||
// Notifications - version
|
// Notifications - version
|
||||||
#define NTF_NET_NEW_RELEASE_AVAILABLE 220
|
#define NTF_NET_NEW_RELEASE_AVAILABLE 220
|
||||||
|
|||||||
Reference in New Issue
Block a user