1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-05 20:33:12 +02:00

Add set::server-notice-colors and oper::server-notice-colors so one

can turn colors in snomask server notices on or off.
This commit is contained in:
Bram Matthys
2021-11-10 08:22:00 +01:00
parent 9f56fb4aa7
commit d74ab4cfb1
5 changed files with 44 additions and 10 deletions
+3 -2
View File
@@ -80,8 +80,9 @@ Enhancements
* See [FAQ: Converting log { } block](https://www.unrealircd.org/docs/FAQ#old-log-block)
on how to change your existing log { } blocks for disk logging.
* We now have a consistent log format and log messages can be multiline.
* Colors are enabled in snomasks and console logs by default. Later there
will be an option to turn this off (TODO).
* Colors are enabled by default in snomask server notices, these can be disabled via
[set::server-notice-colors](https://www.unrealircd.org/docs/Set_block#set::server-notice-colors)
and also in [oper::server-notice-colors](https://www.unrealircd.org/docs/Oper_block)
* Almost all channel modes are modularized
* Only the three list modes (+b/+e/+I) are still in the core
* The five [level modes](https://www.unrealircd.org/docs/Channel_Modes#Access_levels)
+1
View File
@@ -169,6 +169,7 @@ struct Configuration {
char *helpchan;
char *stats_server;
char *sasl_server;
int server_notice_colors;
};
extern MODVAR Configuration iConf;
+1
View File
@@ -1604,6 +1604,7 @@ struct ConfigItem_oper {
unsigned long modes, require_modes;
char *vhost;
int maxlogins;
int server_notice_colors;
};
/** The TLS options that are used in set::tls and otherblocks::tls-options.
+16
View File
@@ -1635,6 +1635,7 @@ void config_setdefaultsettings(Configuration *i)
char tmp[512];
safe_strdup(i->oper_snomask, OPER_SNOMASKS);
i->server_notice_colors = 1;
i->ident_read_timeout = 7;
i->ident_connect_timeout = 3;
i->ban_version_tkl_time = 86400; /* 1d */
@@ -3858,6 +3859,8 @@ int _conf_oper(ConfigFile *conf, ConfigEntry *ce)
oper = safe_alloc(sizeof(ConfigItem_oper));
safe_strdup(oper->name, ce->value);
oper->server_notice_colors = tempiConf.server_notice_colors; /* default */
for (cep = ce->items; cep; cep = cep->next)
{
if (!strcmp(cep->name, "operclass"))
@@ -3900,6 +3903,10 @@ int _conf_oper(ConfigFile *conf, ConfigEntry *ce)
{
safe_strdup(oper->snomask, cep->value);
}
else if (!strcmp(cep->name, "server-notice-colors"))
{
oper->server_notice_colors = config_checkval(cep->value, CFG_YESNO);
}
else if (!strcmp(cep->name, "modes"))
{
oper->modes = set_usermode(cep->value);
@@ -4021,6 +4028,9 @@ int _test_oper(ConfigFile *conf, ConfigEntry *ce)
}
has_snomask = 1;
}
else if (!strcmp(cep->name, "server-notice-colors"))
{
}
/* oper::modes */
else if (!strcmp(cep->name, "modes"))
{
@@ -7116,6 +7126,9 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
else if (!strcmp(cep->name, "snomask-on-oper")) {
safe_strdup(tempiConf.oper_snomask, cep->value);
}
else if (!strcmp(cep->name, "server-notice-colors")) {
tempiConf.server_notice_colors = config_checkval(cep->value, CFG_YESNO);
}
else if (!strcmp(cep->name, "level-on-join")) {
const char *res = channellevel_to_string(cep->value); /* 'halfop', etc */
if (!res)
@@ -7785,6 +7798,9 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce)
CheckNull(cep);
CheckDuplicate(cep, snomask_on_oper, "snomask-on-oper");
}
else if (!strcmp(cep->name, "server-notice-colors")) {
CheckNull(cep);
}
else if (!strcmp(cep->name, "level-on-join")) {
CheckNull(cep);
CheckDuplicate(cep, level_on_join, "level-on-join");
+23 -8
View File
@@ -1446,6 +1446,10 @@ void do_unreal_log_opers(LogLevel loglevel, const char *subsystem, const char *e
/* To specific snomasks... */
list_for_each_entry(client, &oper_list, special_node)
{
const char *operlogin;
ConfigItem_oper *oper;
int colors = iConf.server_notice_colors;
if (snomask_destinations)
{
char found = 0;
@@ -1462,17 +1466,28 @@ void do_unreal_log_opers(LogLevel loglevel, const char *subsystem, const char *e
if (!found)
continue;
}
operlogin = get_operlogin(client);
if (operlogin && (oper = find_oper(operlogin)))
colors = oper->server_notice_colors;
mtags_loop = mtags;
for (m = msg; m; m = m->next)
{
char subsystem_and_event_id[256];
snprintf(subsystem_and_event_id, sizeof(subsystem_and_event_id), "%s%s.%s%s%s",
COLOR_DARKGREY, subsystem, event_id, m->next?"+":"", COLOR_NONE);
sendto_one(client, mtags_loop, ":%s NOTICE %s :%s %s[%s]%s %s",
from_server->name, client->name,
subsystem_and_event_id,
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
m->line);
if (colors)
{
sendto_one(client, mtags_loop, ":%s NOTICE %s :%s%s.%s%s%s %s[%s]%s %s",
from_server->name, client->name,
COLOR_DARKGREY, subsystem, event_id, m->next?"+":"", COLOR_NONE,
log_level_irc_color(loglevel), log_level_valtostring(loglevel), COLOR_NONE,
m->line);
} else {
sendto_one(client, mtags_loop, ":%s NOTICE %s :%s.%s%s [%s] %s",
from_server->name, client->name,
subsystem, event_id, m->next?"+":"",
log_level_valtostring(loglevel),
m->line);
}
mtags_loop = NULL; /* this way we only send the JSON in the first msg */
}
}