diff --git a/doc/RELEASE-NOTES.md b/doc/RELEASE-NOTES.md index 1955529f7..4c5215b52 100644 --- a/doc/RELEASE-NOTES.md +++ b/doc/RELEASE-NOTES.md @@ -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) diff --git a/include/dynconf.h b/include/dynconf.h index 75da652fa..978f4443a 100644 --- a/include/dynconf.h +++ b/include/dynconf.h @@ -169,6 +169,7 @@ struct Configuration { char *helpchan; char *stats_server; char *sasl_server; + int server_notice_colors; }; extern MODVAR Configuration iConf; diff --git a/include/struct.h b/include/struct.h index e734df7c5..2063d7185 100644 --- a/include/struct.h +++ b/include/struct.h @@ -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. diff --git a/src/conf.c b/src/conf.c index e31f0b39c..07e34413b 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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"); diff --git a/src/log.c b/src/log.c index f85f8f8b8..914a57596 100644 --- a/src/log.c +++ b/src/log.c @@ -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 */ } }