Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-09-2008, 06:50 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default IP Limiting Additional Feature and Correction

First, I noticed that setting the exempt status for accounts doesn't actually work to make that status exempt in the current version of IP Limiting. You have to set it 1 higher status on the account than what you set the rule to for it to be exempt. I believe the reason is this check here:

world/clientlist.cpp
Code:
		if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() <= (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) {

And I believe the fix is simple. Just change the <= into a < as shown here in RED:
Code:
		if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) {
That is a pretty minor fix, but a valid one IMO.

=========================================
Everything below this is extra code that is not necessarily needing to be put into the source

NOTE: The new additional feature code below was written by Derision NOT me. I wrote an original version that didn't work properly and Derision completely rewrote it and now it seems to test perfectly.

The new additional feature I added for the IP limiting is the option to allow an extra account status check which would allow a higher number of IP limited accounts to be set. So, if your normal IP limiting is set to 2, then you could set this new rule to 3 to allow accounts with higher status to have 3 accounts per IP. Yes, this could be done by giving the player 1 exempt account, but the reason for making this option is to remove the possibility for people to trick admins into giving them multiple exempt accounts for the purpose of cheating the IP limiting. One example might be a server that wants to allow families to have an extra account or 2 over the IP limit so they can play together. You don't want people tricking you into giving them 10 accounts so they can box massively and completely avoid the IP limiting rule. With this feature, you could set a secondary IP limit restriction for accounts with a different status. If you have status 0 accounts set to limit to 2 per household, you could set status 1 accounts to be limited to 4 per household (or however many you desire). And you can still set another status to be completely exempt from the rule.

I know, it is a little complicated lol. But I do think it would be useful on many servers.

Here is the new code with changes:

clientlist.cpp
Code:
//Lieka && Derision Edit Begin:  Check current CLE Entry IPs against incoming connection

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 the Admin status of the connection is not eligible for the higher limit,
                                // or there is no higher limit (AddMaxClientStatus<0)

                                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();
        }
}
//Lieka & Derision Edit End
ruletypes.h
Code:
RULE_INT ( World, MaxClientsPerIP, -1 ) //Lieka Edit: Maximum number of clients allowed to connect per IP address if account status is < AddMaxClientsStatus.  Default value: -1 (feature disabled)
RULE_INT ( World, ExemptMaxClientsStatus, -1 ) //Lieka Edit: Exempt accounts from the MaxClientsPerIP and AddMaxClientsStatus rules, if their status is >= this value.  Default value: -1 (feature disabled)
RULE_INT ( World, AddMaxClientsPerIP, -1 ) //Trevius Edit: Maximum number of clients allowed to connect per IP address if account status is < ExemptMaxClientsStatus.  Default value: -1 (feature disabled)
RULE_INT ( World, AddMaxClientsStatus, -1 ) //Trevius Edit: Accounts with status >= this rule will be allowed to use the amount of accounts defined in the AddMaxClientsPerIP.  Default value: -1 (feature disabled)
Required SQL:
Code:
Insert into rule_values values (0, 'World:AddMaxClientsPerIP', -1);
Insert into rule_values values (0, 'World:AddMaxClientsStatus', -1);
And an example of how to set them:
World:MaxClientsPerIP 2 //Set IP Limit to 2 accounts
World:AddMaxClientsStatus 1 //Set Additional IP Limit Status of 1
World:AddMaxClientsPerIP 4 //Set Additional IP Limit to 4 Accounts
World:ExemptMaxClientsStatus 20 //Any account of 20 or more is exempt of IP Limiting

That is all that is needed. Though, the rule descriptions could probably be written so they are easier to understand. But, this is difficult for me to explain clearly in short lines like that.

It compiles perfectly. Though, I have yet to test to verify that it actually works as described, but I am pretty sure that it should. At the very least, I think the fix for the current IP Limiting at the top of this post should go into the official source code.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 09-23-2008 at 04:12 PM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:56 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3