From 488706c71dd14cc85e2fdcff6ea3e2ddc1bf2b54 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 14 Feb 2017 14:10:57 +0100 Subject: [PATCH] [Node] Limit servers to 10 per ip --- src/Components/Modules/Node.cpp | 11 +++++++++++ src/Components/Modules/Node.hpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index cee5cfcd..f6ae4650 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -132,6 +132,17 @@ namespace Components } else { + int count = 0; + for(auto entry : Node::Nodes) + { + if(entry.state != Node::STATE_INVALID && entry.address.getIP().full == address.getIP().full) + { + count++; + } + + if (count >= NODE_IP_LIMIT) return; + } + Node::NodeEntry entry; entry.lastHeard = Game::Sys_Milliseconds(); diff --git a/src/Components/Modules/Node.hpp b/src/Components/Modules/Node.hpp index 1ff58df1..79f15a38 100644 --- a/src/Components/Modules/Node.hpp +++ b/src/Components/Modules/Node.hpp @@ -9,6 +9,8 @@ #define NODE_STORE_INTERVAL 1000 * 60* 1 // Store nodes every minute #define SESSION_TIMEOUT 1000 * 10 // 10 seconds session timeout +#define NODE_IP_LIMIT 15 + #define NODE_VERSION 4 namespace Components