35 lines
655 B
C++
35 lines
655 B
C++
#include "IPTable.h"
|
|
|
|
IPTable::IPTable()
|
|
{
|
|
storage.clear();
|
|
}
|
|
|
|
IPTable::IPTable(const IPTable& obj)
|
|
{
|
|
for (auto& ele : obj.storage)
|
|
storage.insert(ele);
|
|
}
|
|
|
|
void IPTable::Appened(DateTime expr_time, IPList list)
|
|
{
|
|
storage.insert(std::pair<DateTime, IPList>(expr_time, list));
|
|
}
|
|
|
|
void IPTable::Update()
|
|
{
|
|
DateTime time = DateTime::Now();
|
|
for (auto it = storage.begin(); it != storage.end(); it++)
|
|
if ((*it).first.GetTimeStamp() <= time.GetTimeStamp())
|
|
storage.erase(it);
|
|
return;
|
|
}
|
|
|
|
bool IPTable::IPExist(std::string ip)
|
|
{
|
|
for (auto& ele : storage)
|
|
if (ele.second.Exist(ip))
|
|
return true;
|
|
return false;
|
|
}
|