1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-10 12:23:13 +02:00

Add named extban support. This only deals with the incoming parsing,

it is not visible outgoing yet. So: ~account:name becomes ~a:name.
This commit is contained in:
Bram Matthys
2021-08-14 09:27:39 +02:00
parent d41e3e0f6e
commit 34b034ab36
3 changed files with 35 additions and 3 deletions
+5
View File
@@ -382,9 +382,13 @@ typedef struct Extban Extban;
struct Extban {
/** extbans module */
Module *owner;
/** extended ban character */
char letter;
/** extended ban name */
char *name;
/** extban options */
ExtbanOptions options;
@@ -406,6 +410,7 @@ struct Extban {
typedef struct {
char letter;
char *name;
ExtbanOptions options;
int (*is_ok)(BanContext *b);
char *(*conv_param)(BanContext *b, Extban *handler);
+18 -1
View File
@@ -55,8 +55,12 @@ Extban *findmod_by_bantype(char *str, char **remainder)
*remainder = p+1;
for (i=0; i <= ExtBan_highest; i++)
{
if (ExtBan_Table[i].letter == str[1])
return &ExtBan_Table[i];
if (ExtBan_Table[i].name && !strncmp(ExtBan_Table[i].name, str+1, p-str-1))
return &ExtBan_Table[i];
}
return NULL;
}
@@ -65,9 +69,20 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
{
int slot;
/* FIXME: FOR TESTING ONLY !!! */
if (!req.name)
{
char *p;
req.name = module->header->name;
p = strrchr(req.name, '/');
if (p)
req.name = p;
}
for (slot=0; slot <= ExtBan_highest; slot++)
{
if (ExtBan_Table[slot].letter == req.letter) // || name.. matches (TODO)
if ((ExtBan_Table[slot].letter == req.letter) ||
(ExtBan_Table[slot].name && !strcasecmp(ExtBan_Table[slot].name, req.name)))
{
if (module)
module->errorcode = MODERR_EXISTS;
@@ -92,6 +107,7 @@ Extban *ExtbanAdd(Module *module, ExtbanInfo req)
}
ExtBan_Table[slot].letter = req.letter;
safe_strdup(ExtBan_Table[slot].name, req.name);
ExtBan_Table[slot].is_ok = req.is_ok;
ExtBan_Table[slot].conv_param = req.conv_param;
ExtBan_Table[slot].is_banned = req.is_banned;
@@ -127,6 +143,7 @@ void ExtbanDel(Extban *eb)
}
}
}
safe_free(eb->name);
memset(eb, 0, sizeof(Extban));
set_isupport_extban();
/* Hmm do we want to go trough all chans and remove the bans?
+12 -2
View File
@@ -1371,7 +1371,17 @@ void send_invalid_channelname(Client *client, char *channelname)
*/
int is_extended_ban(const char *str)
{
if ((str[0] == '~') && (str[1] != '\0') && (str[2] == ':'))
return 1;
const char *p;
if (*str != '~')
return 0;
for (p = str+1; *p; p++)
{
if (!isalnum(*p))
{
if (*p == ':')
return 1;
}
}
return 0;
}