rendered paste body#include "stdafx.h"
#include "BannedClints.h"
#include <iostream>
BannedClients::BannedClients(Cserver& server): m_server(server) ;
std::istream& BannedClients::load(std::istream& is, std::vector<std::string>& storage)
{
std:vector<std::string>::iterator it = *storage.begin();
for (std::string s; getline(is, s); )
{
*storage.insert(it++,s);
}
return is;
}
int BannedClients::load(const std::string& file std::vector<std::string>& storage)
{
std::ifstream is(file.c_str());
if (!is)
return 1;
load(is,storage);
return !is.eof();
}
bool BannedClients::LoadData() {
if(!load(b_peerid_file,b_peerid)&& !load(b_agent_file,b_agent)) {
std::err << "Unable to load banned client data files!";
return true;
}
return false;
}
bool BannedClients::CheckPeer(std::string& peer) {
std::vector<std::string>iterator it;
for (it=b_peer.begin(); it<b_peer.end(); it++) {
if(*it==*peer)
return true;
}
return false;
}
bool BannedClients::CheckAgent(std::string& peer) {
std::vector<std::string>iterator it;
for (it=b_agent.begin(); it<b_agent.end(); it++) {
if(*it==*peer)
return true;
}
return false;
}