Server: pq_connectmute tutorial
Posted: Tue Dec 29, 2009 7:03 am
With mods (at least in NetQuake), traditionally the way the ban file works is that mods read the ban file in and then if the ip address matches a banned ip, the player gets booted.
Vulnerability
It takes at least a fraction of a second for the mod to read the ban file. Maybe 1 second or 2 seconds.
During that time a player can spam chat. With a creative alias, they can connect, chat spam, connect, chat spam, connect chat spam.
And they can ruin a game by doing so, particularly a team game where communication is important. At a minimum it is disruptive. And they aren't supposed to be able to connect to a server they are banned on anyway.
PQ_CONNECTMUTE: # of seconds before a player is allowed to speak upon connecting ...
This engine modification allows the server to only permit chatting after X seconds of being connected. This gives the mod time to read the ban file and execute it. I have ProQuake in dedicated server mod set it to 3 automatically.
I wrote this for ProQuake server about 2 years ago. Actually, R00k walked me through the implementation because at the time I was very new to engine coding.
Anyway, this is a "bandage" to solve this issue. The preferred way would be the engine reading the ban file unless there is a good reason that QuakeC is the "right way" to do this for reasons I am unaware of.
Tutorial (Adapted to GLQuake/WinQuake)
1. in host.c, create a cvar "pq_connectmute" with a default value of 0! Yes zero.
Add this:
We default pq_connectmute to 0 because it is undesireable in single player or a listen server. But for a dedicated server, we will likely want it. GLQuake/WinQuake doesn't have sophisticated cvar defaulting, so we need to set it to 3 in the code if the server is running in dedicated mode.
Add this to SV_Init:
At first glance, you would think this is improper because it would override the value specified in the command line or elsewhere, but it's fine because that all occurs later.
3. Open host_cmd.c and in Host_Say add the yellow:
And banned players spamming chat with a script is no longer possible.
Vulnerability
It takes at least a fraction of a second for the mod to read the ban file. Maybe 1 second or 2 seconds.
During that time a player can spam chat. With a creative alias, they can connect, chat spam, connect, chat spam, connect chat spam.
And they can ruin a game by doing so, particularly a team game where communication is important. At a minimum it is disruptive. And they aren't supposed to be able to connect to a server they are banned on anyway.
PQ_CONNECTMUTE: # of seconds before a player is allowed to speak upon connecting ...
This engine modification allows the server to only permit chatting after X seconds of being connected. This gives the mod time to read the ban file and execute it. I have ProQuake in dedicated server mod set it to 3 automatically.
I wrote this for ProQuake server about 2 years ago. Actually, R00k walked me through the implementation because at the time I was very new to engine coding.
Anyway, this is a "bandage" to solve this issue. The preferred way would be the engine reading the ban file unless there is a good reason that QuakeC is the "right way" to do this for reasons I am unaware of.
Tutorial (Adapted to GLQuake/WinQuake)
1. in host.c, create a cvar "pq_connectmute" with a default value of 0! Yes zero.
Add this:
Add the yellow:// Baker 3.99g - from Rook ... protect against players connecting and spamming before banfile can kick in
cvar_t pq_connectmute = {"pq_connectmute", "0", false, true}; // (value in seconds)
2. sv_main.cCvar_RegisterVariable (&coop);
Cvar_RegisterVariable (&pq_connectmute); // Baker 3.99g: from Rook, protection against repeatedly connecting + spamming
We default pq_connectmute to 0 because it is undesireable in single player or a listen server. But for a dedicated server, we will likely want it. GLQuake/WinQuake doesn't have sophisticated cvar defaulting, so we need to set it to 3 in the code if the server is running in dedicated mode.
Add this to SV_Init:
Code: Select all
// Baker: Dedicated server "defaults" - this is ok because quake.rc is executed later, so these "defaults" won't override config.cfg settings, etc.
if (COM_CheckParm ("-dedicated")) {
Cvar_Set("pq_connectmute", "3"); // Baker 3.99g: "Default" it to 10 seconds
}
3. Open host_cmd.c and in Host_Say add the yellow:
So if pq_connectmute has a value of 3, it will be 3 seconds before the server will allow a player to chat. The ban file will have been read by that time and executed.// turn on color set 1
if (!fromServer)
{
// R00k - dont allow new connecting players to spam obscenities...
if (pq_connectmute.value && (net_time - host_client->netconnection->connecttime) < pq_connectmute.value)
return;
And banned players spamming chat with a script is no longer possible.