Builds with protocol changes (currently untested).

This commit is contained in:
lotodore
2014-12-28 01:01:52 +01:00
parent 47093976ca
commit fdfba430b2
13 changed files with 8521 additions and 3 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -47,6 +47,11 @@ public:
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
@@ -66,9 +71,9 @@ protected:
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateJoinExistingGameMessage(const NetPacket &packet);
static bool ValidateJoinNewGameMessage(const NetPacket &packet);
static bool ValidateRejoinExistingGameMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
@@ -0,0 +1,146 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _NETPACKETVALIDATOR_H_
#define _NETPACKETVALIDATOR_H_
#include <map>
class NetPacket;
class NetGameInfo;
class NetPacketValidator
{
public:
NetPacketValidator();
bool IsValidPacket(const NetPacket &packet) const;
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
static bool ValidateAuthServerVerificationMessage(const NetPacket &packet);
static bool ValidateInitAckMessage(const NetPacket &packet);
static bool ValidateAvatarRequestMessage(const NetPacket &packet);
static bool ValidateAvatarHeaderMessage(const NetPacket &packet);
static bool ValidateAvatarDataMessage(const NetPacket &packet);
static bool ValidateAvatarEndMessage(const NetPacket &packet);
static bool ValidateUnknownAvatarMessage(const NetPacket &packet);
static bool ValidatePlayerListMessage(const NetPacket &packet);
static bool ValidateGameListNewMessage(const NetPacket &packet);
static bool ValidateGameListUpdateMessage(const NetPacket &packet);
static bool ValidateGameListPlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGameListPlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameListAdminChangedMessage(const NetPacket &packet);
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGamePlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameAdminChangedMessage(const NetPacket &packet);
static bool ValidateRemovedFromGameMessage(const NetPacket &packet);
static bool ValidateKickPlayerRequestMessage(const NetPacket &packet);
static bool ValidateLeaveGameRequestMessage(const NetPacket &packet);
static bool ValidateInvitePlayerToGameMessage(const NetPacket &packet);
static bool ValidateInviteNotifyMessage(const NetPacket &packet);
static bool ValidateRejectGameInvitationMessage(const NetPacket &packet);
static bool ValidateRejectInvNotifyMessage(const NetPacket &packet);
static bool ValidateStartEventMessage(const NetPacket &packet);
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
static bool ValidateYourActionRejectedMessage(const NetPacket &packet);
static bool ValidatePlayersActionDoneMessage(const NetPacket &packet);
static bool ValidateDealFlopCardsMessage(const NetPacket &packet);
static bool ValidateDealTurnCardMessage(const NetPacket &packet);
static bool ValidateDealRiverCardMessage(const NetPacket &packet);
static bool ValidateAllInShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandHideCardsMessage(const NetPacket &packet);
static bool ValidateShowMyCardsRequestMessage(const NetPacket &packet);
static bool ValidateAfterHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfGameMessage(const NetPacket &packet);
static bool ValidatePlayerIdChangedMessage(const NetPacket &packet);
static bool ValidateAskKickPlayerMessage(const NetPacket &packet);
static bool ValidateAskKickDeniedMessage(const NetPacket &packet);
static bool ValidateStartKickPetitionMessage(const NetPacket &packet);
static bool ValidateVoteKickRequestMessage(const NetPacket &packet);
static bool ValidateVoteKickReplyMessage(const NetPacket &packet);
static bool ValidateKickPetitionUpdateMessage(const NetPacket &packet);
static bool ValidateEndKickPetitionMessage(const NetPacket &packet);
static bool ValidateStatisticsMessage(const NetPacket &packet);
static bool ValidateChatRequestMessage(const NetPacket &packet);
static bool ValidateChatMessage(const NetPacket &packet);
static bool ValidateChatRejectMessage(const NetPacket &packet);
static bool ValidateDialogMessage(const NetPacket &packet);
static bool ValidateTimeoutWarningMessage(const NetPacket &packet);
static bool ValidateResetTimeoutMessage(const NetPacket &packet);
static bool ValidateReportAvatarMessage(const NetPacket &packet);
static bool ValidateReportAvatarAckMessage(const NetPacket &packet);
static bool ValidateReportGameMessage(const NetPacket &packet);
static bool ValidateReportGameAckMessage(const NetPacket &packet);
static bool ValidateErrorMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameAckMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerAckMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameInfo(const NetGameInfo &gameInfo);
typedef bool (*ValidateFunctor)(const NetPacket &);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif
@@ -0,0 +1,146 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _NETPACKETVALIDATOR_H_
#define _NETPACKETVALIDATOR_H_
#include <map>
class NetPacket;
class NetGameInfo;
class NetPacketValidator
{
public:
NetPacketValidator();
bool IsValidPacket(const NetPacket &packet) const;
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
static bool ValidateAuthServerVerificationMessage(const NetPacket &packet);
static bool ValidateInitAckMessage(const NetPacket &packet);
static bool ValidateAvatarRequestMessage(const NetPacket &packet);
static bool ValidateAvatarHeaderMessage(const NetPacket &packet);
static bool ValidateAvatarDataMessage(const NetPacket &packet);
static bool ValidateAvatarEndMessage(const NetPacket &packet);
static bool ValidateUnknownAvatarMessage(const NetPacket &packet);
static bool ValidatePlayerListMessage(const NetPacket &packet);
static bool ValidateGameListNewMessage(const NetPacket &packet);
static bool ValidateGameListUpdateMessage(const NetPacket &packet);
static bool ValidateGameListPlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGameListPlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameListAdminChangedMessage(const NetPacket &packet);
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGamePlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameAdminChangedMessage(const NetPacket &packet);
static bool ValidateRemovedFromGameMessage(const NetPacket &packet);
static bool ValidateKickPlayerRequestMessage(const NetPacket &packet);
static bool ValidateLeaveGameRequestMessage(const NetPacket &packet);
static bool ValidateInvitePlayerToGameMessage(const NetPacket &packet);
static bool ValidateInviteNotifyMessage(const NetPacket &packet);
static bool ValidateRejectGameInvitationMessage(const NetPacket &packet);
static bool ValidateRejectInvNotifyMessage(const NetPacket &packet);
static bool ValidateStartEventMessage(const NetPacket &packet);
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
static bool ValidateYourActionRejectedMessage(const NetPacket &packet);
static bool ValidatePlayersActionDoneMessage(const NetPacket &packet);
static bool ValidateDealFlopCardsMessage(const NetPacket &packet);
static bool ValidateDealTurnCardMessage(const NetPacket &packet);
static bool ValidateDealRiverCardMessage(const NetPacket &packet);
static bool ValidateAllInShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandHideCardsMessage(const NetPacket &packet);
static bool ValidateShowMyCardsRequestMessage(const NetPacket &packet);
static bool ValidateAfterHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfGameMessage(const NetPacket &packet);
static bool ValidatePlayerIdChangedMessage(const NetPacket &packet);
static bool ValidateAskKickPlayerMessage(const NetPacket &packet);
static bool ValidateAskKickDeniedMessage(const NetPacket &packet);
static bool ValidateStartKickPetitionMessage(const NetPacket &packet);
static bool ValidateVoteKickRequestMessage(const NetPacket &packet);
static bool ValidateVoteKickReplyMessage(const NetPacket &packet);
static bool ValidateKickPetitionUpdateMessage(const NetPacket &packet);
static bool ValidateEndKickPetitionMessage(const NetPacket &packet);
static bool ValidateStatisticsMessage(const NetPacket &packet);
static bool ValidateChatRequestMessage(const NetPacket &packet);
static bool ValidateChatMessage(const NetPacket &packet);
static bool ValidateChatRejectMessage(const NetPacket &packet);
static bool ValidateDialogMessage(const NetPacket &packet);
static bool ValidateTimeoutWarningMessage(const NetPacket &packet);
static bool ValidateResetTimeoutMessage(const NetPacket &packet);
static bool ValidateReportAvatarMessage(const NetPacket &packet);
static bool ValidateReportAvatarAckMessage(const NetPacket &packet);
static bool ValidateReportGameMessage(const NetPacket &packet);
static bool ValidateReportGameAckMessage(const NetPacket &packet);
static bool ValidateErrorMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameAckMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerAckMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameInfo(const NetGameInfo &gameInfo);
typedef bool (*ValidateFunctor)(const NetPacket &);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif
+146
View File
@@ -0,0 +1,146 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _NETPACKETVALIDATOR_H_
#define _NETPACKETVALIDATOR_H_
#include <map>
class NetPacket;
class NetGameInfo;
class NetPacketValidator
{
public:
NetPacketValidator();
bool IsValidPacket(const NetPacket &packet) const;
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
static bool ValidateAuthServerVerificationMessage(const NetPacket &packet);
static bool ValidateInitAckMessage(const NetPacket &packet);
static bool ValidateAvatarRequestMessage(const NetPacket &packet);
static bool ValidateAvatarHeaderMessage(const NetPacket &packet);
static bool ValidateAvatarDataMessage(const NetPacket &packet);
static bool ValidateAvatarEndMessage(const NetPacket &packet);
static bool ValidateUnknownAvatarMessage(const NetPacket &packet);
static bool ValidatePlayerListMessage(const NetPacket &packet);
static bool ValidateGameListNewMessage(const NetPacket &packet);
static bool ValidateGameListUpdateMessage(const NetPacket &packet);
static bool ValidateGameListPlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGameListPlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameListAdminChangedMessage(const NetPacket &packet);
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGamePlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameAdminChangedMessage(const NetPacket &packet);
static bool ValidateRemovedFromGameMessage(const NetPacket &packet);
static bool ValidateKickPlayerRequestMessage(const NetPacket &packet);
static bool ValidateLeaveGameRequestMessage(const NetPacket &packet);
static bool ValidateInvitePlayerToGameMessage(const NetPacket &packet);
static bool ValidateInviteNotifyMessage(const NetPacket &packet);
static bool ValidateRejectGameInvitationMessage(const NetPacket &packet);
static bool ValidateRejectInvNotifyMessage(const NetPacket &packet);
static bool ValidateStartEventMessage(const NetPacket &packet);
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
static bool ValidateYourActionRejectedMessage(const NetPacket &packet);
static bool ValidatePlayersActionDoneMessage(const NetPacket &packet);
static bool ValidateDealFlopCardsMessage(const NetPacket &packet);
static bool ValidateDealTurnCardMessage(const NetPacket &packet);
static bool ValidateDealRiverCardMessage(const NetPacket &packet);
static bool ValidateAllInShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandHideCardsMessage(const NetPacket &packet);
static bool ValidateShowMyCardsRequestMessage(const NetPacket &packet);
static bool ValidateAfterHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfGameMessage(const NetPacket &packet);
static bool ValidatePlayerIdChangedMessage(const NetPacket &packet);
static bool ValidateAskKickPlayerMessage(const NetPacket &packet);
static bool ValidateAskKickDeniedMessage(const NetPacket &packet);
static bool ValidateStartKickPetitionMessage(const NetPacket &packet);
static bool ValidateVoteKickRequestMessage(const NetPacket &packet);
static bool ValidateVoteKickReplyMessage(const NetPacket &packet);
static bool ValidateKickPetitionUpdateMessage(const NetPacket &packet);
static bool ValidateEndKickPetitionMessage(const NetPacket &packet);
static bool ValidateStatisticsMessage(const NetPacket &packet);
static bool ValidateChatRequestMessage(const NetPacket &packet);
static bool ValidateChatMessage(const NetPacket &packet);
static bool ValidateChatRejectMessage(const NetPacket &packet);
static bool ValidateDialogMessage(const NetPacket &packet);
static bool ValidateTimeoutWarningMessage(const NetPacket &packet);
static bool ValidateResetTimeoutMessage(const NetPacket &packet);
static bool ValidateReportAvatarMessage(const NetPacket &packet);
static bool ValidateReportAvatarAckMessage(const NetPacket &packet);
static bool ValidateReportGameMessage(const NetPacket &packet);
static bool ValidateReportGameAckMessage(const NetPacket &packet);
static bool ValidateErrorMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameAckMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerAckMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameInfo(const NetGameInfo &gameInfo);
typedef bool (*ValidateFunctor)(const NetPacket &);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif
+146
View File
@@ -0,0 +1,146 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _NETPACKETVALIDATOR_H_
#define _NETPACKETVALIDATOR_H_
#include <map>
class NetPacket;
class NetGameInfo;
class NetPacketValidator
{
public:
NetPacketValidator();
bool IsValidPacket(const NetPacket &packet) const;
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
static bool ValidateAuthServerVerificationMessage(const NetPacket &packet);
static bool ValidateInitAckMessage(const NetPacket &packet);
static bool ValidateAvatarRequestMessage(const NetPacket &packet);
static bool ValidateAvatarHeaderMessage(const NetPacket &packet);
static bool ValidateAvatarDataMessage(const NetPacket &packet);
static bool ValidateAvatarEndMessage(const NetPacket &packet);
static bool ValidateUnknownAvatarMessage(const NetPacket &packet);
static bool ValidatePlayerListMessage(const NetPacket &packet);
static bool ValidateGameListNewMessage(const NetPacket &packet);
static bool ValidateGameListUpdateMessage(const NetPacket &packet);
static bool ValidateGameListPlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGameListPlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameListAdminChangedMessage(const NetPacket &packet);
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGamePlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameAdminChangedMessage(const NetPacket &packet);
static bool ValidateRemovedFromGameMessage(const NetPacket &packet);
static bool ValidateKickPlayerRequestMessage(const NetPacket &packet);
static bool ValidateLeaveGameRequestMessage(const NetPacket &packet);
static bool ValidateInvitePlayerToGameMessage(const NetPacket &packet);
static bool ValidateInviteNotifyMessage(const NetPacket &packet);
static bool ValidateRejectGameInvitationMessage(const NetPacket &packet);
static bool ValidateRejectInvNotifyMessage(const NetPacket &packet);
static bool ValidateStartEventMessage(const NetPacket &packet);
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
static bool ValidateYourActionRejectedMessage(const NetPacket &packet);
static bool ValidatePlayersActionDoneMessage(const NetPacket &packet);
static bool ValidateDealFlopCardsMessage(const NetPacket &packet);
static bool ValidateDealTurnCardMessage(const NetPacket &packet);
static bool ValidateDealRiverCardMessage(const NetPacket &packet);
static bool ValidateAllInShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandHideCardsMessage(const NetPacket &packet);
static bool ValidateShowMyCardsRequestMessage(const NetPacket &packet);
static bool ValidateAfterHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfGameMessage(const NetPacket &packet);
static bool ValidatePlayerIdChangedMessage(const NetPacket &packet);
static bool ValidateAskKickPlayerMessage(const NetPacket &packet);
static bool ValidateAskKickDeniedMessage(const NetPacket &packet);
static bool ValidateStartKickPetitionMessage(const NetPacket &packet);
static bool ValidateVoteKickRequestMessage(const NetPacket &packet);
static bool ValidateVoteKickReplyMessage(const NetPacket &packet);
static bool ValidateKickPetitionUpdateMessage(const NetPacket &packet);
static bool ValidateEndKickPetitionMessage(const NetPacket &packet);
static bool ValidateStatisticsMessage(const NetPacket &packet);
static bool ValidateChatRequestMessage(const NetPacket &packet);
static bool ValidateChatMessage(const NetPacket &packet);
static bool ValidateChatRejectMessage(const NetPacket &packet);
static bool ValidateDialogMessage(const NetPacket &packet);
static bool ValidateTimeoutWarningMessage(const NetPacket &packet);
static bool ValidateResetTimeoutMessage(const NetPacket &packet);
static bool ValidateReportAvatarMessage(const NetPacket &packet);
static bool ValidateReportAvatarAckMessage(const NetPacket &packet);
static bool ValidateReportGameMessage(const NetPacket &packet);
static bool ValidateReportGameAckMessage(const NetPacket &packet);
static bool ValidateErrorMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameAckMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerAckMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameInfo(const NetGameInfo &gameInfo);
typedef bool (*ValidateFunctor)(const NetPacket &);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif
@@ -0,0 +1,146 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _NETPACKETVALIDATOR_H_
#define _NETPACKETVALIDATOR_H_
#include <map>
class NetPacket;
class NetGameInfo;
class NetPacketValidator
{
public:
NetPacketValidator();
bool IsValidPacket(const NetPacket &packet) const;
protected:
static bool ValidateAnnounceMessage(const NetPacket &packet);
static bool ValidateAuthMessage(const NetPacket &packet);
static bool ValidateLobbyMessage(const NetPacket &packet);
static bool ValidateGameMessage(const NetPacket &packet);
static bool ValidateGameManagementMessage(const NetPacket &packet);
static bool ValidateGameEngineMessage(const NetPacket &packet);
static bool ValidateInitMessage(const NetPacket &packet);
static bool ValidateAuthServerChallengeMessage(const NetPacket &packet);
static bool ValidateAuthClientResponseMessage(const NetPacket &packet);
static bool ValidateAuthServerVerificationMessage(const NetPacket &packet);
static bool ValidateInitAckMessage(const NetPacket &packet);
static bool ValidateAvatarRequestMessage(const NetPacket &packet);
static bool ValidateAvatarHeaderMessage(const NetPacket &packet);
static bool ValidateAvatarDataMessage(const NetPacket &packet);
static bool ValidateAvatarEndMessage(const NetPacket &packet);
static bool ValidateUnknownAvatarMessage(const NetPacket &packet);
static bool ValidatePlayerListMessage(const NetPacket &packet);
static bool ValidateGameListNewMessage(const NetPacket &packet);
static bool ValidateGameListUpdateMessage(const NetPacket &packet);
static bool ValidateGameListPlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGameListPlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameListAdminChangedMessage(const NetPacket &packet);
static bool ValidatePlayerInfoRequestMessage(const NetPacket &packet);
static bool ValidatePlayerInfoReplyMessage(const NetPacket &packet);
static bool ValidateSubscriptionRequestMessage(const NetPacket &packet);
static bool ValidateCreateGameMessage(const NetPacket &packet);
static bool ValidateJoinGameMessage(const NetPacket &packet);
static bool ValidateRejoinGameMessage(const NetPacket &packet);
static bool ValidateJoinGameAckMessage(const NetPacket &packet);
static bool ValidateJoinGameFailedMessage(const NetPacket &packet);
static bool ValidateGamePlayerJoinedMessage(const NetPacket &packet);
static bool ValidateGamePlayerLeftMessage(const NetPacket &packet);
static bool ValidateGameAdminChangedMessage(const NetPacket &packet);
static bool ValidateRemovedFromGameMessage(const NetPacket &packet);
static bool ValidateKickPlayerRequestMessage(const NetPacket &packet);
static bool ValidateLeaveGameRequestMessage(const NetPacket &packet);
static bool ValidateInvitePlayerToGameMessage(const NetPacket &packet);
static bool ValidateInviteNotifyMessage(const NetPacket &packet);
static bool ValidateRejectGameInvitationMessage(const NetPacket &packet);
static bool ValidateRejectInvNotifyMessage(const NetPacket &packet);
static bool ValidateStartEventMessage(const NetPacket &packet);
static bool ValidateStartEventAckMessage(const NetPacket &packet);
static bool ValidateGameStartInitialMessage(const NetPacket &packet);
static bool ValidateGameStartRejoinMessage(const NetPacket &packet);
static bool ValidateHandStartMessage(const NetPacket &packet);
static bool ValidatePlayersTurnMessage(const NetPacket &packet);
static bool ValidateMyActionRequestMessage(const NetPacket &packet);
static bool ValidateYourActionRejectedMessage(const NetPacket &packet);
static bool ValidatePlayersActionDoneMessage(const NetPacket &packet);
static bool ValidateDealFlopCardsMessage(const NetPacket &packet);
static bool ValidateDealTurnCardMessage(const NetPacket &packet);
static bool ValidateDealRiverCardMessage(const NetPacket &packet);
static bool ValidateAllInShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfHandHideCardsMessage(const NetPacket &packet);
static bool ValidateShowMyCardsRequestMessage(const NetPacket &packet);
static bool ValidateAfterHandShowCardsMessage(const NetPacket &packet);
static bool ValidateEndOfGameMessage(const NetPacket &packet);
static bool ValidatePlayerIdChangedMessage(const NetPacket &packet);
static bool ValidateAskKickPlayerMessage(const NetPacket &packet);
static bool ValidateAskKickDeniedMessage(const NetPacket &packet);
static bool ValidateStartKickPetitionMessage(const NetPacket &packet);
static bool ValidateVoteKickRequestMessage(const NetPacket &packet);
static bool ValidateVoteKickReplyMessage(const NetPacket &packet);
static bool ValidateKickPetitionUpdateMessage(const NetPacket &packet);
static bool ValidateEndKickPetitionMessage(const NetPacket &packet);
static bool ValidateStatisticsMessage(const NetPacket &packet);
static bool ValidateChatRequestMessage(const NetPacket &packet);
static bool ValidateChatMessage(const NetPacket &packet);
static bool ValidateChatRejectMessage(const NetPacket &packet);
static bool ValidateDialogMessage(const NetPacket &packet);
static bool ValidateTimeoutWarningMessage(const NetPacket &packet);
static bool ValidateResetTimeoutMessage(const NetPacket &packet);
static bool ValidateReportAvatarMessage(const NetPacket &packet);
static bool ValidateReportAvatarAckMessage(const NetPacket &packet);
static bool ValidateReportGameMessage(const NetPacket &packet);
static bool ValidateReportGameAckMessage(const NetPacket &packet);
static bool ValidateErrorMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameMessage(const NetPacket &packet);
static bool ValidateAdminRemoveGameAckMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerMessage(const NetPacket &packet);
static bool ValidateAdminBanPlayerAckMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameListSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameSpectatorJoinedMessage(const NetPacket &packet);
static bool ValidateGameSpectatorLeftMessage(const NetPacket &packet);
static bool ValidateGameInfo(const NetGameInfo &gameInfo);
typedef bool (*ValidateFunctor)(const NetPacket &);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif
+67
View File
@@ -0,0 +1,67 @@
/*****************************************************************************
* PokerTH - The open source texas holdem engine *
* Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* *
* Additional permission under GNU AGPL version 3 section 7 *
* *
* If you modify this program, or any covered work, by linking or *
* combining it with the OpenSSL project's OpenSSL library (or a *
* modified version of that library), containing parts covered by the *
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
* permission to convey the resulting work. *
* Corresponding Source for a non-source form of such a combination *
* shall include the source code for the parts of OpenSSL used as well *
* as that of the covered work. *
*****************************************************************************/
/* PokerTH network packet validation. */
#ifndef _POKERTHMESSAGEVALIDATOR_H_
#define _POKERTHMESSAGEVALIDATOR_H_
#include <map>
class PokerTHMessage;
#define VALIDATE_IS_UINT16(__val) ((__val) <= 65535)
#define VALIDATE_STRING_SIZE(__str, __minsize, __maxsize) ((__str).size() >= (__minsize) && (__str).size() <= (__maxsize))
#define VALIDATE_UINT_RANGE(__val, __minval, __maxval) ((__val) >= (__minval) && (__val) <= (__maxval))
#define VALIDATE_UINT_UPPER(__val, __maxval) ((__val) <= (__maxval))
#define VALIDATE_LIST_SIZE(__l, __minsize, __maxsize) ((__l).size() >= (__minsize) && (__l).size() <= (__maxsize))
class PokerTHMessageValidator
{
public:
PokerTHMessageValidator();
bool IsValidMessage(const PokerTHMessage &msg) const;
protected:
static bool ValidateAnnounceMessage(const PokerTHMessage &msg);
static bool ValidateAuthMessage(const PokerTHMessage &msg);
static bool ValidateLobbyMessage(const PokerTHMessage &msg);
static bool ValidateGameMessage(const PokerTHMessage &msg);
typedef bool (*ValidateFunctor)(const PokerTHMessage &msg);
typedef std::map<int, ValidateFunctor> ValidateFunctorMap;
private:
ValidateFunctorMap m_validationMap;
};
#endif