Skip to content

Commit

Permalink
improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Pryancito committed Feb 3, 2024
1 parent 862b8bf commit d0ea279
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ extern Memos MemoMsg;
std::mutex mutex_srv;

bool Server::CheckClone(const std::string &ip) {
if (ip == "127.0.0.1")
return false;
unsigned int i = 0;
auto it = Users.begin();
for (; it != Users.end(); ++it) {
if (it->second)
if (it->second->mHost == ip)
i++;
}
unsigned int clones = OperServ::IsException(ip, "clon");
if (clones != 0 && i <= clones)
return false;
return (i >= config["clones"].as<unsigned int>());
if (ip == "127.0.0.1") {
return false; // No se consideran clones en la IP local
}

// Cuenta los usuarios conectados desde la IP especificada
auto numClones = std::count_if(Users.begin(), Users.end(),
[&ip](const auto& userPair) { return userPair.second && userPair.second->mHost == ip; });

// Comprueba si hay excepciones para la IP
unsigned int clonesExcepcion = OperServ::IsException(ip, "clon");
if (clonesExcepcion != 0 && numClones <= clonesExcepcion) {
return false; // La IP tiene excepción para permitir más clones
}

// Compara con el límite configurado
return numClones >= config["clones"].as<unsigned int>();
}

bool Server::CheckThrottle(const std::string &ip) {
Expand Down

0 comments on commit d0ea279

Please sign in to comment.