map<string,string> EQW::GetPlayerDetails(Const_char *char_name) { map<string,string> res; ClientListEntry *cle = client_list.FindCharacter(char_name); if(cle == NULL) { res["error"] = "1"; return(res); } res["character"] = cle->name(); res["account"] = cle->AccountName(); res["account_id"] = itoa(cle->AccountID()); res["location_short"] = cle->zone()?database.GetZoneName(cle->zone()):"No Zone"; res["location_long"] = res["location_short"]; res["location_id"] = itoa(cle->zone()); res["ip"] = long2ip(cle->GetIP()); res["level"] = itoa(cle->level()); res["race"] = GetRaceName(cle->race()); res["race_id"] = itoa(cle->race()); res["class"] = GetEQClassName(cle->class_()); res["class_id"] = itoa(cle->class_()); res["guild_id"] = itoa(cle->GuildID()); res["guild"] = guild_mgr.GetGuildName(cle->GuildID()); res["status"] = itoa(cle->Admin()); // res["patch"] = cle->DescribePatch(); return(res); }
void ClientList::GetCLEIP(int32 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()) { // 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))) { // 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)) { // Remove the connection countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; } } } iterator.Advance(); } }
void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName) { LinkedListIterator<ClientListEntry*> iterator(clientlist); char* output = 0; uint32 outsize = 0, outlen = 0; int x = 0, y = 0; int namestrlen = iName == 0 ? 0 : strlen(iName); bool addnewline = false; char newline[3]; if (connection->IsConsole()) strcpy(newline, "\r\n"); else strcpy(newline, "^"); iterator.Reset(); while(iterator.MoreElements()) { ClientListEntry* cle = iterator.GetData(); if (admin >= cle->Admin() && (iName == 0 || namestrlen == 0 || strncasecmp(cle->name(), iName, namestrlen) == 0 || strncasecmp(cle->AccountName(), iName, namestrlen) == 0 || strncasecmp(cle->LSName(), iName, namestrlen) == 0)) { struct in_addr in; in.s_addr = cle->GetIP(); if (addnewline) { AppendAnyLenString(&output, &outsize, &outlen, newline); } AppendAnyLenString(&output, &outsize, &outlen, "ID: %i Acc# %i AccName: %s IP: %s", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in)); AppendAnyLenString(&output, &outsize, &outlen, "%s Stale: %i Online: %i Admin: %i", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin()); if (cle->LSID()) AppendAnyLenString(&output, &outsize, &outlen, "%s LSID: %i LSName: %s WorldAdmin: %i", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin()); if (cle->CharID()) AppendAnyLenString(&output, &outsize, &outlen, "%s CharID: %i CharName: %s Zone: %s (%i)", newline, cle->CharID(), cle->name(), database.GetZoneName(cle->zone()), cle->zone()); if (outlen >= 3072) { connection->SendEmoteMessageRaw(to, 0, 0, 10, output); safe_delete(output); outsize = 0; outlen = 0; addnewline = false; } else addnewline = true; y++; } iterator.Advance(); x++; } AppendAnyLenString(&output, &outsize, &outlen, "%s%i CLEs in memory. %i CLEs listed. numplayers = %i.", newline, x, y, numplayers); connection->SendEmoteMessageRaw(to, 0, 0, 10, output); safe_delete(output); }
void ClientList::DisconnectByIP(uint32 iIP) { ClientListEntry* countCLEIPs = 0; LinkedListIterator<ClientListEntry*> iterator(clientlist); iterator.Reset(); while(iterator.MoreElements()) { countCLEIPs = iterator.GetData(); if ((countCLEIPs->GetIP() == iIP)) { if(strlen(countCLEIPs->name())) { ServerPacket* pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct)); ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer; strcpy(skp->adminname, "SessionLimit"); strcpy(skp->name, countCLEIPs->name()); skp->adminrank = 255; zoneserver_list.SendPacket(pack); safe_delete(pack); } countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); } 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(); } }