1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-28 08:16:38 +02:00

Integrate security-group functionality in tld::mask.

This commit is contained in:
Bram Matthys
2022-05-14 08:10:20 +02:00
parent 759908ba3a
commit ec4df2da7d
3 changed files with 33 additions and 11 deletions
+1 -1
View File
@@ -1683,7 +1683,7 @@ struct ConfigItem_ulines {
struct ConfigItem_tld {
ConfigItem_tld *prev, *next;
ConfigFlag_tld flag;
ConfigItem_mask *mask;
SecurityGroup *match;
char *channel;
char *motd_file, *rules_file, *smotd_file;
char *botmotd_file, *opermotd_file;
+25 -7
View File
@@ -3037,7 +3037,7 @@ ConfigItem_tld *find_tld(Client *client)
for (tld = conf_tld; tld; tld = tld->next)
{
if (unreal_mask_match(client, tld->mask))
if (user_allowed_by_security_group(client, tld->match))
{
if ((tld->options & TLD_TLS) && !IsSecureConnect(client))
continue;
@@ -4621,8 +4621,8 @@ int _conf_tld(ConfigFile *conf, ConfigEntry *ce)
for (cep = ce->items; cep; cep = cep->next)
{
if (!strcmp(cep->name, "mask"))
unreal_add_masks(&ca->mask, cep);
if (!strcmp(cep->name, "match") || !strcmp(cep->name, "mask"))
conf_match_block(conf, cep, &ca->match);
else if (!strcmp(cep->name, "motd"))
{
safe_strdup(ca->motd_file, cep->value);
@@ -4671,8 +4671,8 @@ int _test_tld(ConfigFile *conf, ConfigEntry *ce)
ConfigEntry *cep;
int errors = 0;
int fd = -1;
char has_mask = 0, has_motd = 0, has_rules = 0, has_shortmotd = 0, has_channel = 0;
char has_opermotd = 0, has_botmotd = 0, has_options = 0;
char has_mask = 0, has_match = 0, has_motd = 0, has_rules = 0, has_shortmotd = 0;
char has_channel = 0, has_opermotd = 0, has_botmotd = 0, has_options = 0;
for (cep = ce->items; cep; cep = cep->next)
{
@@ -4687,7 +4687,18 @@ int _test_tld(ConfigFile *conf, ConfigEntry *ce)
if (!strcmp(cep->name, "mask"))
{
if (cep->value || cep->items)
{
has_mask = 1;
test_match_block(conf, cep, &errors);
}
}
else if (!strcmp(cep->name, "match"))
{
if (cep->value || cep->items)
{
has_match = 1;
test_match_block(conf, cep, &errors);
}
}
/* tld::motd */
else if (!strcmp(cep->name, "motd"))
@@ -4837,10 +4848,17 @@ int _test_tld(ConfigFile *conf, ConfigEntry *ce)
continue;
}
}
if (!has_mask)
if (!has_mask && !has_match)
{
config_error_missing(ce->file->filename, ce->line_number,
"tld::mask");
"tld::match");
errors++;
}
if (has_mask && has_match)
{
config_error("%s:%d: You cannot have both ::mask and ::match. "
"You should only use %s::match.",
ce->file->filename, ce->line_number, ce->name);
errors++;
}
if (!has_motd)
+7 -3
View File
@@ -935,12 +935,16 @@ int stats_set(Client *client, const char *para)
int stats_tld(Client *client, const char *para)
{
ConfigItem_tld *tld;
ConfigItem_mask *m;
NameValuePrioList *m;
for (tld = conf_tld; tld; tld = tld->next)
{
for (m = tld->mask; m; m = m->next)
sendnumeric(client, RPL_STATSTLINE, m->mask, tld->motd_file, tld->rules_file ? tld->rules_file : "none");
for (m = tld->match->printable_list; m; m = m->next)
{
sendnumeric(client, RPL_STATSTLINE, namevalue_nospaces(m),
tld->motd_file,
tld->rules_file ? tld->rules_file : "none");
}
}
return 0;