Feel free to submit some code for a better way to do it
I am not much of a coder, but this was a pretty easy way to do something that I needed on my own server. I figured other servers might be able to use it as well, which is why I submitted it. Most servers probably wouldn't need more than 1 or 2 levels of IP limiting. But I do agree that your idea is probably a little better way of handling it to allow more options. And I like having more options
After thinking more about it, the whole IP limiting code is slightly flawed in 1 major way. The problem is that it only checks the status of the current account trying to log in instead of checking the status of all accounts logged in from the same IP. So, even if you have an exempt account, if you don't log the exempt account in last after the others are all in, you won't be able to have more than whatever the IP Limit is set to. As long as you log in the exempt accounts after the others are logged in, you can log in more than the IP Limit.
So, what really needs to be done is there needs to be a check of the status of all accounts logged in from the same IP. Then, it needs to subtract the exempt accounts from the total IP Connections before doing the IP Limit restriction.
Here is an example of how it should work:
Account 1 = Status 0
Account 2 = Status 1
Account 3 = Status 2
Account 4 = Status 3
Account 5 = Status 4
Account 6 = Status 5
IP Limiting set to 2 for all status 0 accounts.
AddMaxClientStatus (for additional accounts) IP limiting set to status 1
IP Limiting Exempt set to status 5
Any account with higher than the AddMaxClientStatus would have 1 more connection allowed added to their total IP Limit. Anything between status 1 and 4 will increment the total accounts allowed by 1. So, status 1 would be limited to 3 accounts per IP, status 2 would be limited to 4 accounts per IP and so on.
When an account is logged in, it would pull all of the accounts connected on that IP. The first thing it would do would be to subtract any exempt accounts from the total IP Connections. Next, it would go down the list of other statuses and run a check:
(Account Status - AddMaxClientStatus + 1) = Total Additional Accounts Per IP. Of course you would have to check to make sure this is >= 0 otherwise any account below AddMaxClientStatus - 1 will go into the negative.
Now that we have the total additional accounts that should be allowed per IP for this account, we can just do (total accounts + MaxClientsPerIP) to get the total for this connection.
The last part would just need to be able to pull the next highest account status below the exempt setting for all accounts connected on that same IP. And that status is what would be used for all connections (other than the exempt ones) to decide how many connections are allowed.
This makes my head hurt a little to think about and to make sure it would word exactly the way that it should. But, I am fairly certain that this way would work. If someone can write some code that can check the status of all accounts connected per IP and then select the highest status that is below the exempt status, I am pretty sure I can write the rest of it. The rest is mostly just adding and subtracting and should be fairly simple.
If this was made, I think it would finalize the IP limiting feature options.
The only other issue with IP Limiting is for Windows Servers. Due to player ghosting on Windows, the IP Limiting feature can lock out players from being able to connect at all if they have a ghost in the world already. The best solution for this would obviously be to fix the player ghosting issue on Windows Servers (it doesn't happen on Linux). But, another solution would be to limit it so that only 1 character can be logged in per account like they do on EQLive. Then, if the same account is logged in again, it will boot any characters currently logged in or even at at character select on that same account. This would cause any ghosted characters to be booted from the world as soon as the same account hit "connect" from the server select. And this check would need to be done before the IP Limiting check to make sure that it boots the character being being IP blocked.
I am definitely learning alot about coding just reading through the source and making minor changes. But, I am still very much of a noob at it, so anything that can't be done by example from somewhere else in the code is above me. That is why I would need someone else to write code that would check the status of all accounts on the same IP connection and select the next highest status below the exempt status. But again, if someone does that, I should be able to do the rest to get this feature working 100% as it should.