added: IP ban mechanism (not finished yet -- we need a winix function to remove a ban)

now after some incorrent login attempts your IP can be banned or blocked
       (see new config variables)


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@902 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-10-27 07:44:26 +00:00
parent 53b4175d00
commit 099dd55d0c
54 changed files with 2691 additions and 1266 deletions

56
core/ipbancontainer.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2012, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfile_winix_core_ipbancontainer
#define headerfile_winix_core_ipbancontainer
#include <vector>
#include "ipban.h"
class IPBanContainer
{
public:
IPBanContainer();
IPBan & AddIP(int ip);
IPBan * FindIP(int ip);
void Sort();
size_t Size();
IPBan & GetIPBan(size_t index);
void SetMaxSize(size_t soft_size, size_t size);
private:
std::vector<IPBan> ipban_tab;
bool is_ipban_tab_sorted;
size_t soft_max_size, max_size;
std::vector<size_t> sort_helper_tab;
static bool SortIPBansFunction(const IPBan & ip1, const IPBan & ip2);
void RemoveOldRecords();
void PrintTab();
void PrintTab2();
struct SortByLastUsedHelper
{
IPBanContainer * container;
SortByLastUsedHelper(IPBanContainer * c) : container(c) {}
bool operator()(size_t index1, size_t index2);
};
};
#endif