From 150a80efa878252ddbc9ceda8282a257d88e284f Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Thu, 29 Sep 2016 11:07:01 -0500 Subject: [PATCH] add connections per ip limit to the connection server (public port only) --- .../src/shared/ConfigConnectionServer.cpp | 1 + .../src/shared/ConfigConnectionServer.h | 7 +++++++ .../src/shared/ConnectionServer.cpp | 14 +++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.cpp index 3166c33a..b06dbe14 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.cpp @@ -88,6 +88,7 @@ void ConfigConnectionServer::install(void) KEY_INT (lagReportThreshold, 10000); KEY_INT (defaultGameFeatures, 0xFFFFFFFF); KEY_INT (defaultSubscriptionFeatures, 0xFFFFFFFF); + KEY_INT (maxConnectionsPerIP, 6); KEY_BOOL (validateStationKey, false); KEY_STRING (sessionServers, ""); diff --git a/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.h b/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.h index a2ed16c5..f3337ce3 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.h +++ b/engine/server/application/ConnectionServer/src/shared/ConfigConnectionServer.h @@ -42,6 +42,7 @@ public: int clientMaxDataHoldTime; int clientHashTableSize; int lagReportThreshold; + int maxConnectionsPerIP; bool validateStationKey; const char * sessionServers; @@ -133,6 +134,7 @@ public: static bool getValidateClientVersion(); static int getConnectionServerNumber(); + static int getMaxConnectionsPerIP(); static int getFakeBuddyPoints(); static const char * getPublicBindAddress(); @@ -465,4 +467,9 @@ inline int ConfigConnectionServer::getConnectionServerNumber() return data->connectionServerNumber; } +inline const int ConfigConnectionServer::getMaxConnectionsPerIP() +{ + return data->maxConnectionsPerIP; +} + #endif // _ConfigConnectionServer_H diff --git a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp index a4f9b5c0..5a8d523b 100755 --- a/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp +++ b/engine/server/application/ConnectionServer/src/shared/ConnectionServer.cpp @@ -110,6 +110,7 @@ ConnectionServer::ConnectionServer() : s_clientServiceSetup->maxDataHoldTime = ConfigConnectionServer::getClientMaxDataHoldTime(); s_clientServiceSetup->hashTableSize = ConfigConnectionServer::getClientHashTableSize(); s_clientServiceSetup->port = ConfigConnectionServer::getClientServicePortPublic(); + s_clientServiceSetup->maxConnectionsPerIP = ConfigConnectionServer::getMaxConnectionsPerIP(); s_clientServiceSetup->compress = ConfigConnectionServer::getCompressClientNetworkTraffic(); s_clientServiceSetup->useTcp = false; @@ -556,15 +557,17 @@ void ConnectionServer::receiveMessage(const MessageDispatch::Emitter & source, c { DEBUG_REPORT_LOG(true, ("Opened connection with central\n")); centralConnection = const_cast(static_cast(&source));//lint !e826 // info: Suspiscious pointer-to-pointer conversion (area too small) - if (s_clientServiceSetup == 0) - s_clientServiceSetup = new NetworkSetupData; - s_clientServiceSetup->useTcp = false; if (ConfigConnectionServer::getStartPublicServer()) + { + s_clientServiceSetup->port = ConfigConnectionServer::getClientServicePortPublic(); + s_clientServiceSetup->maxConnectionsPerIP = ConfigConnectionServer::getMaxConnectionsPerIP(); clientServicePublic = new Service(ConnectionAllocator(), *s_clientServiceSetup); + } + s_clientServiceSetup->port = ConfigConnectionServer::getClientServicePortPrivate(); + s_clientServiceSetup->maxConnectionsPerIP = 0; clientServicePrivate = new Service(ConnectionAllocator(), *s_clientServiceSetup); - s_clientServiceSetup->port = ConfigConnectionServer::getClientServicePortPublic(); connectToMessage("ClientConnectionOpened"); connectToMessage("ClientConnectionClosed"); @@ -608,8 +611,9 @@ void ConnectionServer::receiveMessage(const MessageDispatch::Emitter & source, c } else { + // TODO: wtf is this? @Darth, fix it! //If they aren't connected to the game yet, they're probably on the pending list. -// removePendingCharacter(cconn->getSUID()); + //removePendingCharacter(cconn->getSUID()); } removeFromConnectedMap(cconn->getSUID()); }