-#if defined(CSQC)
-#elif defined(MENUQC)
-#elif defined(SVQC)
- #include "../dpdefs/progsdefs.qh"
- #include "../dpdefs/dpextensions.qh"
- #include "../common/constants.qh"
- #include "../common/util.qh"
- #include "autocvars.qh"
- #include "defs.qh"
- #include "command/banning.qh"
- #include "ipban.qh"
-#endif
+#include "ipban.qh"
+
+#include "autocvars.qh"
+#include "command/banning.qh"
+#include "defs.qh"
+#include "../common/constants.qh"
+#include "../common/util.qh"
/*
* Protocol of online ban list:
if(id >= MAX_IPBAN_URIS)
{
- print("Received ban list for invalid ID\n");
+ LOG_INFO("Received ban list for invalid ID\n");
return;
}
tokenize_console(autocvar_g_ban_sync_uri);
uri = argv(id);
- print("Received ban list from ", uri, ": ");
+ LOG_INFO("Received ban list from ", uri, ": ");
if(OnlineBanList_RequestWaiting[id] == 0)
{
- print("rejected (unexpected)\n");
+ LOG_INFO("rejected (unexpected)\n");
return;
}
if(time > OnlineBanList_Timeout)
{
- print("rejected (too late)\n");
+ LOG_INFO("rejected (too late)\n");
return;
}
syncinterval = autocvar_g_ban_sync_interval;
if(syncinterval == 0)
{
- print("rejected (syncing disabled)\n");
+ LOG_INFO("rejected (syncing disabled)\n");
return;
}
if(syncinterval > 0)
if(status != 0)
{
- print("error: status is ", ftos(status), "\n");
+ LOG_INFO("error: status is ", ftos(status), "\n");
return;
}
if(substring(data, 0, 1) == "<")
{
- print("error: received HTML instead of a ban list\n");
+ LOG_INFO("error: received HTML instead of a ban list\n");
return;
}
if(strstrofs(data, "\r", 0) != -1)
{
- print("error: received carriage returns\n");
+ LOG_INFO("error: received carriage returns\n");
return;
}
if((n % 4) != 0)
{
- print("error: received invalid item count: ", ftos(n), "\n");
+ LOG_INFO("error: received invalid item count: ", ftos(n), "\n");
return;
}
- print("OK, ", ftos(n / 4), " items\n");
+ LOG_INFO("OK, ", ftos(n / 4), " items\n");
for(i = 0; i < n; i += 4)
{
reason = argv(i + 2);
serverip = argv(i + 3);
- dprint("received ban list item ", ftos(i / 4), ": ip=", ip);
- dprint(" timeleft=", ftos(timeleft), " reason=", reason);
- dprint(" serverip=", serverip, "\n");
+ LOG_TRACE("received ban list item ", ftos(i / 4), ": ip=", ip);
+ LOG_TRACE(" timeleft=", ftos(timeleft), " reason=", reason);
+ LOG_TRACE(" serverip=", serverip, "\n");
timeleft -= 1.5 * autocvar_g_ban_sync_timeout;
if(timeleft < 0)
for(j = 0; j < l; ++j)
if(strstrofs("0123456789.", substring(ip, j, 1), 0) == -1)
{
- print("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
+ LOG_INFO("Invalid character ", substring(ip, j, 1), " in IP address ", ip, ". Skipping this ban.\n");
goto skip;
}
}
// the ban will be prolonged on the next sync
// or expire 5 seconds after the next timeout
Ban_Insert(ip, timeleft, strcat("ban synced from ", serverip, " at ", uri), 0);
- print("Ban list syncing: accepted ban of ", ip, " by ", serverip, " at ", uri, ": ");
- print(reason, "\n");
+ LOG_INFO("Ban list syncing: accepted ban of ", ip, " by ", serverip, " at ", uri, ": ");
+ LOG_INFO(reason, "\n");
:skip
}
}
void OnlineBanList_Think()
-{
+{SELFPARAM();
float argc;
string uri;
float i, n;
}
}
- entity e;
- e = spawn();
- e.classname = "bansyncer";
+ entity e = new(bansyncer);
e.think = OnlineBanList_Think;
e.nextthink = time + 1;
}
float i, n;
string msg;
- print("^2Listing all existing active bans:\n");
+ LOG_INFO("^2Listing all existing active bans:\n");
n = 0;
for(i = 0; i < ban_count; ++i)
msg = strcat(msg, ban_ip[i], " is still banned for ");
msg = strcat(msg, ftos(ban_expire[i] - time), " seconds");
- print(" ", msg, "\n");
+ LOG_INFO(" ", msg, "\n");
}
- print("^2Done listing all active (", ftos(n), ") bans.\n");
+ LOG_INFO("^2Done listing all active (", ftos(n), ") bans.\n");
}
float Ban_GetClientIP(entity client)
float i1, i2, i3, i4;
string s;
- if(client.crypto_keyfp)
+ if(client.crypto_idfp_signed)
ban_idfp = client.crypto_idfp;
else
ban_idfp = string_null;
if(time + bantime > ban_expire[i])
{
ban_expire[i] = time + bantime;
- dprint(ip, "'s ban has been prolonged to ", ftos(bantime), " seconds from now\n");
+ LOG_TRACE(ip, "'s ban has been prolonged to ", ftos(bantime), " seconds from now\n");
}
else
- dprint(ip, "'s ban is still active until ", ftos(ban_expire[i] - time), " seconds from now\n");
+ LOG_TRACE(ip, "'s ban is still active until ", ftos(ban_expire[i] - time), " seconds from now\n");
// and enforce
reason = Ban_Enforce(i, reason);
if(i < ban_count)
if(ban_expire[i] > time + bantime)
{
- print(ip, " could not get banned due to no free ban slot\n");
+ LOG_INFO(ip, " could not get banned due to no free ban slot\n");
return false;
}
// okay, insert our new victim as i
Ban_Delete(i);
- dprint(ip, " has been banned for ", ftos(bantime), " seconds\n");
+ LOG_TRACE(ip, " has been banned for ", ftos(bantime), " seconds\n");
ban_expire[i] = time + bantime;
ban_ip[i] = strzone(ip);
ban_count = max(ban_count, i + 1);