Author SHA1 Message Date
q4z1 a333185525 Merge branch 'stable' of https://github.com/pokerth/pokerth into stable 2020-07-21 16:05:56 +02:00
q4z1 7d116d7294 IP address output in server_messages.log in order to handle Server Attack 2020-07-21 16:05:20 +02:00
Kai Philipp 0cd9ba6f99 Merge pull request #403 from zormit/gitignore-fixes
fix gitignore: don't ignore certain patterns of subdirectories
2020-07-06 17:04:56 +02:00
Moritz Neeb 99ad7ffd71 fix gitignore: don't ignore certain patterns of subdirectories
the project has source code in paths like:

    tests/src/de/pokerth
    src/chatcleaner

which should not be ignored. To fix this, a slash needs to be added in
front of the files that actually should be ignored.

While at it:
- pokerth_server does not need to be ignored (it's generated in `bin/`,
  which is ignored already)
- ignore some project files (for the case Eclipse is used as IDE)
2020-07-04 23:11:18 +02:00
q4z1 9b36c9863c bottleneck handling 2020-03-22 09:59:45 +01:00
8 changed files with 24 additions and 223 deletions
+4 -3
View File
@@ -8,14 +8,15 @@ Makefile.pokerth_protocol
Makefile.pokerth_server
Makefile.pokerth_dbofficial
bin/
chatcleaner
/chatcleaner
lib/
mocs/
obj/
pokerth
/pokerth
qrc_pokerth.cpp
uics/
make.sh
gitpush_serverstuff_stable
pokerth_server
.vscode/
.project
.classpath
-86
View File
@@ -1,86 +0,0 @@
# QMake pro-file for the PokerTH dedicated server
isEmpty( PREFIX ){
PREFIX =/usr
}
TEMPLATE = app
CODECFORSRC = UTF-8
CONFIG += thread console embed_manifest_exe exceptions rtti stl warn_on
UI_DIR = uics
TARGET = bin/dealer_random_test
MOC_DIR = mocs
OBJECTS_DIR = obj
DEFINES += PREFIX=\"$${PREFIX}\"
QT -= core gui
#PRECOMPILED_HEADER = src/pch_lib.h
INCLUDEPATH += . \
src
DEPENDPATH += . \
src
# Input
SOURCES += \
src/dealer_random_test.cpp
unix : !mac {
##### My release static build options
#QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
#QMAKE_LFLAGS += -Wl,--gc-sections
QMAKE_LIBDIR += lib $${PREFIX}/lib /opt/gsasl/lib
INCLUDEPATH += $${PREFIX}/include
LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
BOOST_PROGRAM_OPTIONS = boost_program_options boost_program_options-mt
BOOST_SYS = boost_system boost_system-mt
#
# searching in $PREFIX/lib, $PREFIX/lib64 and $$system($$QMAKE_QMAKE -query QT_INSTALL_LIBS)
# to override the default '/usr' pass PREFIX
# variable to qmake.
#
for(dir, LIB_DIRS){
exists($$dir){
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_PROGRAM_OPTIONS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_PROGRAM_OPTIONS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.so*) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
for(lib, BOOST_SYS):exists($${dir}/lib$${lib}.a) {
message("Found $$lib")
BOOST_SYS = -l$$lib
}
}
}
BOOST_LIBS = $$BOOST_PROGRAM_OPTIONS $$BOOST_SYS
!count(BOOST_LIBS, 2){
error("Unable to find boost libraries in PREFIX=$${PREFIX}")
}
UNAME = $$system(uname -s)
BSD = $$find(UNAME, "BSD")
kFreeBSD = $$find(UNAME, "kFreeBSD")
LIBS += $$BOOST_LIBS
LIBS += -lprotobuf -lgsasl -lgcrypt -lidn -lboost_thread -lboost_system -lboost_random
#### INSTALL ####
binary.path += $${PREFIX}/bin/
binary.files += dealer_random_test
INSTALLS += binary
}
-115
View File
@@ -1,115 +0,0 @@
/*****************************************************************************
* 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. *
*****************************************************************************/
// Connectivity test program for PokerTH
#include <iostream>
#include <boost/program_options.hpp>
#include <boost/thread.hpp>
#include <boost/nondet_random.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/variate_generator.hpp>
using namespace std;
namespace po = boost::program_options;
boost::thread_specific_ptr<boost::random_device> g_rand_state;
struct nondet_rng : std::unary_function<unsigned, unsigned> {
boost::random_device &_state;
unsigned operator()(unsigned i)
{
boost::uniform_int<> rng(0, i - 1);
return rng(_state);
}
nondet_rng(boost::random_device &state) : _state(state) {}
};
int
main(int argc, char *argv[])
{
try {
// Check command line options.
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
("num,n", po::value<int>(), "set num of deals")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << endl;
return 1;
}
if (!vm.count("num")) {
cout << "Missing option!" << endl << desc << endl;
return 1;
}
int num = vm["num"].as<int>();
const int NumCards = 52;
for(int i=0; i<num;i++){
// shuffle cards
int cardsArray[NumCards] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
50, 51
};
if (!g_rand_state.get()) {
g_rand_state.reset(new boost::random_device);
}
nondet_rng rand(*g_rand_state);
random_shuffle(&cardsArray[0], &cardsArray[NumCards], rand);
ostringstream oss("");
for (int temp = 0; temp < NumCards; temp++){
if(temp > 0) cout << ",";
cout << cardsArray[temp];
}
cout << endl;
}
} catch (...) {
cout << "Exception caught" << endl;
return 1;
}
return 0;
}
+3 -3
View File
@@ -105,7 +105,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
size_t packetSize = ntohl(nativeVal);
if (packetSize > MAX_PACKET_SIZE) {
recvBufUsed = 0;
LOG_ERROR("Session " << session->GetId() << " - Invalid packet size: " << packetSize);
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet size: " << packetSize);
} else if (recvBufUsed >= packetSize + NET_HEADER_SIZE) {
try {
tmpPacket = NetPacket::Create(&recvBuf[NET_HEADER_SIZE], packetSize);
@@ -118,7 +118,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
} catch (const exception &e) {
// Reset buffer on error.
recvBufUsed = 0;
LOG_ERROR("Session " << session->GetId() << " - " << e.what());
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - " << e.what());
}
}
}
@@ -126,7 +126,7 @@ AsioReceiveBuffer::ScanPackets(boost::shared_ptr<SessionData> session)
if (validator.IsValidPacket(*tmpPacket)) {
receivedPackets.push_back(tmpPacket);
} else {
LOG_ERROR("Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
LOG_ERROR(session->GetClientAddr() << "Session " << session->GetId() << " - Invalid packet: " << tmpPacket->GetMsg()->messagetype());
}
} else {
dataAvailable = false;
+4 -3
View File
@@ -63,8 +63,9 @@
#include <boost/algorithm/string.hpp>
#include <gsasl.h>
#include <ctime>
#include <string>
#define SERVER_MAX_NUM_LOBBY_SESSIONS 512 // Maximum number of idle users in lobby.
#define SERVER_MAX_NUM_LOBBY_SESSIONS 1536 // Maximum number of idle users in lobby.
#define SERVER_MAX_NUM_TOTAL_SESSIONS 2000 // Total maximum of sessions, fitting a 2048 handle limit
#define SERVER_SAVE_STATISTICS_INTERVAL_SEC 60
@@ -304,8 +305,8 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<SessionData> sessionData)
// Create a new session.
m_sessionManager.AddSession(sessionData);
LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << ".");
LOG_ERROR("Accepted connection - session #" << sessionData->GetId() << ".");
LOG_VERBOSE(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
LOG_ERROR(sessionData->GetRemoteIPAddressFromSocket() << " Accepted connection - session #" << sessionData->GetId() << ".");
sessionData->StartTimerInitTimeout(SERVER_INIT_SESSION_TIMEOUT_SEC);
sessionData->StartTimerGlobalTimeout(SERVER_SESSION_FORCED_TIMEOUT_SEC);
+1 -1
View File
@@ -23806,7 +23806,7 @@ bool ErrorMessage_ErrorReason_IsValid(int value) {
}
#ifndef _MSC_VER
const ErrorMessage_ErrorReason ErrorMessage::reserved;
const ErrorMessage_ErrorReason ErrorMessage::custReserved;
const ErrorMessage_ErrorReason ErrorMessage::initVersionNotSupported;
const ErrorMessage_ErrorReason ErrorMessage::initServerFull;
const ErrorMessage_ErrorReason ErrorMessage::initAuthFailure;
+3 -3
View File
@@ -345,7 +345,7 @@ const ReportGameAckMessage_ReportGameResult ReportGameAckMessage_ReportGameResul
const int ReportGameAckMessage_ReportGameResult_ReportGameResult_ARRAYSIZE = ReportGameAckMessage_ReportGameResult_ReportGameResult_MAX + 1;
enum ErrorMessage_ErrorReason {
ErrorMessage_ErrorReason_reserved = 0,
ErrorMessage_ErrorReason_custReserved = 0,
ErrorMessage_ErrorReason_initVersionNotSupported = 1,
ErrorMessage_ErrorReason_initServerFull = 2,
ErrorMessage_ErrorReason_initAuthFailure = 3,
@@ -362,7 +362,7 @@ enum ErrorMessage_ErrorReason {
ErrorMessage_ErrorReason_sessionTimeout = 14
};
bool ErrorMessage_ErrorReason_IsValid(int value);
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_reserved;
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MIN = ErrorMessage_ErrorReason_custReserved;
const ErrorMessage_ErrorReason ErrorMessage_ErrorReason_ErrorReason_MAX = ErrorMessage_ErrorReason_sessionTimeout;
const int ErrorMessage_ErrorReason_ErrorReason_ARRAYSIZE = ErrorMessage_ErrorReason_ErrorReason_MAX + 1;
@@ -10416,7 +10416,7 @@ class ErrorMessage : public ::google::protobuf::MessageLite {
// nested types ----------------------------------------------------
typedef ErrorMessage_ErrorReason ErrorReason;
static const ErrorReason reserved = ErrorMessage_ErrorReason_reserved;
static const ErrorReason custReserved = ErrorMessage_ErrorReason_custReserved;
static const ErrorReason initVersionNotSupported = ErrorMessage_ErrorReason_initVersionNotSupported;
static const ErrorReason initServerFull = ErrorMessage_ErrorReason_initServerFull;
static const ErrorReason initAuthFailure = ErrorMessage_ErrorReason_initAuthFailure;
+9 -9
View File
@@ -48996,9 +48996,9 @@ public final class ProtoBuf {
public enum ErrorReason
implements com.google.protobuf.Internal.EnumLite {
/**
* <code>reserved = 0;</code>
* <code>custReserved = 0;</code>
*/
reserved(0, 0),
custReserved(0, 0),
/**
* <code>initVersionNotSupported = 1;</code>
*/
@@ -49058,9 +49058,9 @@ public final class ProtoBuf {
;
/**
* <code>reserved = 0;</code>
* <code>custReserved = 0;</code>
*/
public static final int reserved_VALUE = 0;
public static final int custReserved_VALUE = 0;
/**
* <code>initVersionNotSupported = 1;</code>
*/
@@ -49123,7 +49123,7 @@ public final class ProtoBuf {
public static ErrorReason valueOf(int value) {
switch (value) {
case 0: return reserved;
case 0: return custReserved;
case 1: return initVersionNotSupported;
case 2: return initServerFull;
case 3: return initAuthFailure;
@@ -49180,7 +49180,7 @@ public final class ProtoBuf {
}
private void initFields() {
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
@@ -49309,7 +49309,7 @@ public final class ProtoBuf {
public Builder clear() {
super.clear();
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
bitField0_ = (bitField0_ & ~0x00000001);
return this;
}
@@ -49379,7 +49379,7 @@ public final class ProtoBuf {
}
private int bitField0_;
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
private de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
/**
* <code>required .ErrorMessage.ErrorReason errorReason = 1;</code>
*/
@@ -49409,7 +49409,7 @@ public final class ProtoBuf {
*/
public Builder clearErrorReason() {
bitField0_ = (bitField0_ & ~0x00000001);
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.reserved;
errorReason_ = de.pokerth.protocol.ProtoBuf.ErrorMessage.ErrorReason.custReserved;
return this;
}