mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-08 17:22:18 +00:00
Merge branch 'allow-banip-mask' into 'next'
Allow ban masks to be specified for banip See merge request STJr/SRB2!2272
This commit is contained in:
commit
2cfbcf7fbf
1 changed files with 13 additions and 2 deletions
|
@ -274,7 +274,9 @@ void Command_BanIP(void)
|
||||||
|
|
||||||
if (server) // Only the server can use this, otherwise does nothing.
|
if (server) // Only the server can use this, otherwise does nothing.
|
||||||
{
|
{
|
||||||
|
char *addrbuf = NULL;
|
||||||
const char *address = (COM_Argv(1));
|
const char *address = (COM_Argv(1));
|
||||||
|
const char *mask = strchr(address, '/');
|
||||||
const char *reason;
|
const char *reason;
|
||||||
|
|
||||||
if (COM_Argc() == 2)
|
if (COM_Argc() == 2)
|
||||||
|
@ -282,8 +284,16 @@ void Command_BanIP(void)
|
||||||
else
|
else
|
||||||
reason = COM_Argv(2);
|
reason = COM_Argv(2);
|
||||||
|
|
||||||
|
if (mask != NULL)
|
||||||
|
{
|
||||||
|
addrbuf = Z_Malloc(mask - address + 1, PU_STATIC, NULL);
|
||||||
|
memcpy(addrbuf, address, mask - address);
|
||||||
|
addrbuf[mask - address] = '\0';
|
||||||
|
address = addrbuf;
|
||||||
|
mask++;
|
||||||
|
}
|
||||||
|
|
||||||
if (I_SetBanAddress && I_SetBanAddress(address, NULL))
|
if (I_SetBanAddress && I_SetBanAddress(address, mask))
|
||||||
{
|
{
|
||||||
if (reason)
|
if (reason)
|
||||||
CONS_Printf("Banned IP address %s for: %s\n", address, reason);
|
CONS_Printf("Banned IP address %s for: %s\n", address, reason);
|
||||||
|
@ -295,8 +305,9 @@ void Command_BanIP(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
CONS_Printf("Unable to apply ban: address in malformed or invalid, or too many bans are applied\n");
|
||||||
}
|
}
|
||||||
|
Z_Free(addrbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue