Files
winix/core/ipbancontainer.h
Tomasz Sowa 9ef3736989 added: to 'ipban' winix function:
possibility to remove a ban (or all bans)
added: to SessionManager: sorting of the ban list (in the second thread)



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@903 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-10-27 09:03:49 +00:00

59 lines
1.0 KiB
C++

/*
* 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);
void RemoveIP(int ip);
void Clear();
bool IsSorted();
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