Add general::hidden_caps

This commit is contained in:
Ed Kellett 2020-11-08 00:25:54 +00:00
parent 8e1bdeda92
commit 6ac21a70e2
4 changed files with 48 additions and 0 deletions

View file

@ -235,6 +235,8 @@ struct config_file_entry
int away_interval;
int tls_ciphers_oper_only;
char **hidden_caps;
int client_flood_max_lines;
int client_flood_burst_rate;
int client_flood_burst_max;

View file

@ -1665,6 +1665,30 @@ conf_set_general_oper_snomask(void *data)
}
}
static void
conf_set_general_hidden_caps(void *data)
{
size_t n = 0;
for (conf_parm_t *arg = data; arg; arg = arg->next)
n += 1;
if (ConfigFileEntry.hidden_caps != NULL)
{
for (n = 0; ConfigFileEntry.hidden_caps[n] != NULL; n++)
rb_free(ConfigFileEntry.hidden_caps[n]);
rb_free(ConfigFileEntry.hidden_caps);
}
ConfigFileEntry.hidden_caps = rb_malloc(sizeof *ConfigFileEntry.hidden_caps * (n + 1));
n = 0;
for (conf_parm_t *arg = data; arg; arg = arg->next)
{
ConfigFileEntry.hidden_caps[n++] = rb_strdup(arg->v.string);
}
ConfigFileEntry.hidden_caps[n] = NULL;
}
static void
conf_set_serverhide_links_delay(void *data)
{
@ -2645,6 +2669,8 @@ static struct ConfEntry conf_general_table[] =
{ "non_redundant_klines", CF_YESNO, NULL, 0, &ConfigFileEntry.non_redundant_klines },
{ "tkline_expire_notices", CF_YESNO, NULL, 0, &ConfigFileEntry.tkline_expire_notices },
{ "hidden_caps", CF_QSTRING | CF_FLIST, conf_set_general_hidden_caps, 0, NULL },
{ "anti_nick_flood", CF_YESNO, NULL, 0, &ConfigFileEntry.anti_nick_flood },
{ "burst_away", CF_YESNO, NULL, 0, &ConfigFileEntry.burst_away },
{ "caller_id_wait", CF_TIME, NULL, 0, &ConfigFileEntry.caller_id_wait },

View file

@ -1535,6 +1535,14 @@ clear_out_old_conf(void)
rb_free(ConfigFileEntry.sasl_service);
ConfigFileEntry.sasl_service = NULL;
if (ConfigFileEntry.hidden_caps != NULL)
{
for (size_t i = 0; ConfigFileEntry.hidden_caps[i] != NULL; i++)
rb_free(ConfigFileEntry.hidden_caps[i]);
rb_free(ConfigFileEntry.hidden_caps);
}
ConfigFileEntry.hidden_caps = NULL;
/* clean out log */
rb_free(ConfigFileEntry.fname_userlog);
ConfigFileEntry.fname_userlog = NULL;

View file

@ -187,6 +187,18 @@ clicap_generate(struct Client *source_p, const char *subcmd, int flags)
else if (pass == 1 && HasCapabilityFlag(entry, CLICAP_FLAGS_PRIORITY))
continue;
if (!IsCapableEntry(source_p, entry) && ConfigFileEntry.hidden_caps != NULL)
{
size_t i;
for (i = 0; ConfigFileEntry.hidden_caps[i] != NULL; i++)
{
if (!rb_strcasecmp(entry->cap, ConfigFileEntry.hidden_caps[i]))
break;
}
if (ConfigFileEntry.hidden_caps[i] != NULL)
continue;
}
if (flags && !IsCapableEntry(source_p, entry))
continue;