void ClientList::GetCLEIP(uint32 iIP) { ClientListEntry* countCLEIPs = 0; LinkedListIterator<ClientListEntry*> iterator(clientlist); int IPInstances = 0; iterator.Reset(); while(iterator.MoreElements()) { countCLEIPs = iterator.GetData(); // If the IP matches, and the connection admin status is below the exempt status, // or exempt status is less than 0 (no-one is exempt) if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // Increment the occurences of this IP address IPInstances++; // If the number of connections exceeds the lower limit if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules if (RuleB(World, MaxClientsSetByStatus)) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP if (IPInstances > countCLEIPs->Admin()) { if(RuleB(World, IPLimitDisconnectAll)) { DisconnectByIP(iIP); return; } else { // Remove the connection countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; } } } // Else if the Admin status of the connection is not eligible for the higher limit, // or there is no higher limit (AddMaxClientStatus<0) else if ((countCLEIPs->Admin() < (RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0))) { if(RuleB(World, IPLimitDisconnectAll)) { DisconnectByIP(iIP); return; } else { // Remove the connection countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; } } // else they are eligible for the higher limit, but if they exceed that else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { if(RuleB(World, IPLimitDisconnectAll)) { DisconnectByIP(iIP); return; } else { // Remove the connection countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; } } } } iterator.Advance(); } }
void ClientList::GetCLEIP(uint32 iIP) { ClientListEntry* countCLEIPs = 0; LinkedListIterator<ClientListEntry*> iterator(clientlist); int IPInstances = 0; iterator.Reset(); while(iterator.MoreElements()) { countCLEIPs = iterator.GetData(); if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // If the IP matches, and the connection admin status is below the exempt status, or exempt status is less than 0 (no-one is exempt) IPInstances++; // Increment the occurences of this IP address Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); if (RuleB(World, EnableIPExemptions)) { Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())); if (IPInstances > database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())) { if(RuleB(World, IPLimitDisconnectAll)) { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; } } } else { if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If the number of connections exceeds the lower limit if (RuleB(World, MaxClientsSetByStatus)) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin()); if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP if(RuleB(World, IPLimitDisconnectAll)) { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; } } } else if ((countCLEIPs->Admin() < RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0)) { // Else if the Admin status of the connection is not eligible for the higher limit, or there is no higher limit (AddMaxClientStatus < 0) if(RuleB(World, IPLimitDisconnectAll)) { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; } } else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that if(RuleB(World, IPLimitDisconnectAll)) { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; } } } } } iterator.Advance(); } }