Banning from Servers
by Justin Mette · in Torque Game Engine · 12/05/2003 (10:24 am) · 4 replies
Hi, I was wondering if anyone has updated Torque to resurect the banning feature from T2? The code is in engine\game\banList.cc.
In particular, the following function:
Doesn't bother to check the second parameter which is the IP address. The first GUID parameter is hard coded to 0 for all players because it used to be the Authentication ID from Won.net for T2.
So the way this works now is if one person is banned from a server, all players are banned (because they all have a guid of 0).
Has anyone updated this function to comapare IP addresses or used another mechanism of detecting players?
Justin
In particular, the following function:
bool BanList::isBanned(S32 uniqueId, const char *)
{
S32 curTime = Platform::getTime();
Vector<BanInfo>::iterator i;
for(i = list.begin();i != list.end();)
{
if(i->bannedUntil != 0 && i->bannedUntil < curTime)
{
list.erase(i);
continue;
}
else if(uniqueId == i->uniqueId)
return true;
i++;
}
return false;
}Doesn't bother to check the second parameter which is the IP address. The first GUID parameter is hard coded to 0 for all players because it used to be the Authentication ID from Won.net for T2.
So the way this works now is if one person is banned from a server, all players are banned (because they all have a guid of 0).
Has anyone updated this function to comapare IP addresses or used another mechanism of detecting players?
Justin
#2
I still would like the ability to ban by IP though, hmmm.
12/05/2003 (10:46 am)
Thanks for pointing me at that - it is a nice resource. Unfortunately, it requires a GUID to be integrated into the game from an auth server or something. Have to think about that one.I still would like the ability to ban by IP though, hmmm.
#3
-Ron
12/05/2003 (10:52 am)
Banning by IP could get hairy, especialy with todays DHCP'ed cable modem accounts, dial-up accounts etc. Banning a person by IP could end up banning the wrong chap. a UID would be the best choice, that is if each user had there own UID. Could you piggy back off you DB backend app and gen a unique UID for each player? toss that back to the game and store it?-Ron
#4
To
Then add the following function
This should encode the first three places in their IP address into a hex string that you can use for the GUID. It's not perfect but it is will get you up and running.
NOTE: I haven't tested this in game yet, I wrote this at work :)
12/05/2003 (10:56 am)
In clientConnection.cs change the following:%client.guid = 0;
To
%client.guid = guidFromAddress(%client.getAddress());
Then add the following function
function guidFromAddress(%address)
{
%address = strreplace(%address,"."," ");
%hexascii = "0123456789ABCDEF";
%guid = "";
for (%i = 0; %i < 4; %i++)
{
%dec = getWord(%address,%i);
if (%dec > 255)
{
%dec = 255;
}
%val0 = mFloor(%dec/16);
%val1 = %dec - (%val0 * 16);
%c1 = getSubStr(%hexascii,%val0,1);
%c2 = getSubStr(%hexascii,%val1,1);
%hex = %c1 @ %c2;
%guid = %guid @ %hex;
}
return %guid;
}This should encode the first three places in their IP address into a hex string that you can use for the GUID. It's not perfect but it is will get you up and running.
NOTE: I haven't tested this in game yet, I wrote this at work :)
Torque 3D Owner Chris "DiGi" Timberlake