PDA

View Full Version : Example - Alternate IP Restriction Approach


Shodai82
03-17-2020, 10:53 AM
On UltimateEQ I've had max ip set to 3 for a long time now. While it works mostly as expected, the way the logic is implemented in the eqemu source (as far as I understand it), when a player logs out/disconnects/leaves the world, there is often a lag time that will not allow you to log in another character. This usually presents itself as "You have been disconnected" when trying to log in during this scenario. To work around this I implemented the following in global_player, event_enterzone (after updating max ips to -1 in the rules table):


if($zoneid != 344 && $zoneid != 151) { #exempt zones
if (!$client->GetGM()) {
my @exemptAccounts = ("###");

if (!grep{$_ eq $client->AccountName()} @exemptAccounts) {
my @clist = $entity_list->GetClientList();
my $ipCount = 0;
my @playerNames = ();

foreach my $n (@clist) {
if ($n->GetIP() == $client->GetIP()) {
$ipCount = $ipCount + 1;
push @playerNames, $n->GetCleanName();
}
}

if ($ipCount > 3) {
$client->WorldKick();
foreach my $playerName (@playerNames) {
my $currentClient = $entity_list->GetClientByName($playerName);
$currentClient->Message(5, "Your client count exceeded the maximum amount per ip address (3). The client was disconnected.");
}
}
}
}
}

Hopefully this is helpful for some. There are some enhancements you could do, such as querying the world instead of the current zones entity_list, but for my purposes (preventing mass zergs of players on content), it works quite well.

chrsschb
03-17-2020, 11:50 AM
Awesome. Now if only I could figure out how to rewrite it to work globally and check ip_exemptions table :D

I do like the concept of having an exempt zone though. People can pile their chars into hub zones for buffs and stuff without restriction.

Shodai82
03-17-2020, 12:23 PM
I initially did exactly that. Using event_connect and event_disconnect (or enterzone) you can get the character ip, write it to a custom table via perl DBI, then just query that table. The downside to this is performance implications at scale and that I do not believe event_disconnect is triggered on server shutdown (I wasn't willing to test this live, haha). Of course you could always purge the table on startup.

theoneptd
02-03-2021, 05:02 PM
Something really needs to be done. If a server allows only 3 per IP, and one of your characters crash while zoning (which happens often in emu) you have to sit there and wait for the timeout before you can get past the character select screen.