[Node] Limit servers to 10 per ip

This commit is contained in:
momo5502 2017-02-14 14:10:57 +01:00
parent d8ab3ab422
commit 488706c71d
2 changed files with 13 additions and 0 deletions

View File

@ -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();

View File

@ -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