Add a rule, MaxClientsSimplifiedLogic which allows for P99-style IP restrictions if enabled. Opcode handler for OP_WorldLogout in char sel.

Only uses ExemptAccountLimitStatus and MaxClientsPerIP. Also adds in an
opcode handler so CLEs are cleaned up at char select when ESC is
pressed.
This commit is contained in:
E Spause 2017-03-12 23:19:24 -04:00
parent 3fa72218a4
commit 3dd0d43e96
5 changed files with 41 additions and 1 deletions

View File

@ -663,6 +663,7 @@ struct UsertoWorldRequest_Struct {
uint32 worldid;
uint32 FromID;
uint32 ToID;
char IPAddr[64];
};
struct UsertoWorldResponse_Struct {

View File

@ -1022,6 +1022,12 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
eqs->Close();
return true;
}
case OP_WorldLogout:
{
eqs->Close();
cle->SetOnline(CLE_Status_Offline); //allows this player to log in again without an ip restriction.
return false;
}
case OP_ZoneChange:
{
// HoT sends this to world while zoning and wants it echoed back.

View File

@ -214,6 +214,24 @@ void ClientList::GetCLEIP(uint32 iIP) {
}
}
uint32 ClientList::GetCLEIPCount(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)) && countCLEIPs->Online() >= CLE_Status_Online) { // 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
}
iterator.Advance();
}
return IPInstances;
}
void ClientList::DisconnectByIP(uint32 iIP) {
ClientListEntry* countCLEIPs = 0;
LinkedListIterator<ClientListEntry*> iterator(clientlist);
@ -252,7 +270,6 @@ ClientListEntry* ClientList::FindCharacter(const char* name) {
return 0;
}
ClientListEntry* ClientList::FindCLEByAccountID(uint32 iAccID) {
LinkedListIterator<ClientListEntry*> iterator(clientlist);

View File

@ -56,6 +56,7 @@ public:
ClientListEntry* FindCLEByCharacterID(uint32 iCharID);
ClientListEntry* GetCLE(uint32 iID);
void GetCLEIP(uint32 iIP);
uint32 GetCLEIPCount(uint32 iLSAccountID);
void DisconnectByIP(uint32 iIP);
void EnforceSessionLimit(uint32 iLSAccountID);
void CLCheckStale();

View File

@ -134,11 +134,26 @@ bool LoginServer::Process() {
if( (int32)numplayers >= x && x != -1 && x != 255 && status < 80)
utwrs->response = -3;
if (pack->size == sizeof(UsertoWorldRequest_Struct))
{
uint32 decimalIP = inet_addr(utwr->IPAddr);
if (RuleB(World, MaxClientsSimplifiedLogic)) {
if (client_list.GetCLEIPCount(decimalIP) >= (RuleI(World, MaxClientsPerIP))) {
if ((status < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0)) {
utwrs->response = -4;
}
}
}
}
if(status == -1)
utwrs->response = -1;
if(status == -2)
utwrs->response = -2;
utwrs->worldid = utwr->worldid;
SendPacket(outpack);
delete outpack;