Files
UNSWebServerCore_LinuxSO/IPTable.cpp
T
2026-06-30 17:49:51 +08:00

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;
}