1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00

Some minor updates to previous.

* We try to keep the dynconf variables the same name as in the conf
  (well, with hyphens to underscores, and there are some exceptions)
* Remove unnecessary but otherwise harmless second safe_free()
* The URL could have been too long. It is now limited to 360 characters,
  which should be plenty.
This commit is contained in:
Bram Matthys
2025-11-12 10:11:57 +01:00
parent 557595fd1c
commit 68f01814be
3 changed files with 14 additions and 13 deletions
+3 -3
View File
@@ -189,7 +189,7 @@ struct Configuration {
int dns_dnsbl_retry;
int send_isupport_updates;
int utf8_only;
char *network_icon_url;
char *network_icon;
};
extern MODVAR Configuration iConf;
@@ -293,7 +293,7 @@ extern MODVAR BestPractices bestpractices;
#define UTF8ONLY iConf.utf8_only
#define NETWORK_ICON iConf.network_icon_url
#define NETWORK_ICON iConf.network_icon
/** Used for testing the set { } block configuration.
* It tests if a setting is present and is also used for duplicate checking.
@@ -347,7 +347,7 @@ struct SetCheck {
unsigned has_spamfilter_virus_help_channel_deny:1;
unsigned has_spamfilter_except:1;
unsigned has_network_name:1;
unsigned has_network_icon_url:1;
unsigned has_network_icon:1;
unsigned has_default_server:1;
unsigned has_services_server:1;
unsigned has_sasl_server:1;
+2 -2
View File
@@ -121,8 +121,8 @@ void isupport_init(void)
else
ISupportDelByName("UHNAMES");
ISupportSet(NULL, "DEAF", "d");
if (settings.has_network_icon_url)
ISupportSet(NULL, "draft/ICON", iConf.network_icon_url);
if (settings.has_network_icon)
ISupportSet(NULL, "draft/ICON", iConf.network_icon);
else
ISupportDelByName("draft/ICON");
+9 -8
View File
@@ -1691,7 +1691,7 @@ void free_iConf(Configuration *i)
safe_free(i->reject_message_gline);
safe_free(i->network_name);
safe_free(i->network_name_005);
safe_free(i->network_icon_url);
safe_free(i->network_icon);
safe_free(i->default_server);
safe_free(i->services_name);
safe_free(i->cloak_prefix);
@@ -1702,7 +1702,6 @@ void free_iConf(Configuration *i)
safe_free_all_ban_actions(i->handshake_data_flood_ban_action);
safe_free(i->central_spamfilter_url);
safe_free(i->central_spamfilter_feed);
safe_free(i->network_icon_url);
free_security_group(i->central_spamfilter_except);
// anti-flood:
for (f = i->floodsettings; f; f = f_next)
@@ -8336,7 +8335,7 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
}
}
} else if (!strcmp(cep->name, "network-icon")) {
safe_strdup(tempiConf.network_icon_url, cep->value);
safe_strdup(tempiConf.network_icon, cep->value);
} else if (config_set_dynamic_set_block_item(conf, &dynamic_set, cep))
{
/* Handled by config_set_dynamic_set_block_item - nothing to do here */
@@ -8652,16 +8651,18 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce)
}
else if (!strcmp(cep->name, "network-icon")) {
CheckNull(cep);
CheckDuplicate(cep, network_icon_url, "network-icon");
CheckDuplicate(cep, network_icon, "network-icon");
if (strncmp(cep->value, "https://", 8) != 0) {
config_error("%s:%i: set::network-icon URL must be single-quoted and start with 'https://' like 'https://example.com/image.jpg'",
cep->file->filename, cep->line_number);
errors++;
}
// length of IRC line minus server name length and other 005 lengths
int max_url_len = (512 - strlen(me.name) - 8);
if (strlen(cep->value) > max_url_len) {
/* Maximum URL length is (with a few characters margin):
* 510 (IRC protocol line) - 55 for the static text (whitespace, ":", "375", "draft/ICON=", ":are supported by this server", etc)
* - HOSTLEN (lazy me.name max) - NICKLEN (max nick length)
* Which comes down to 360 which should be plenty.
*/
if (strlen(cep->value) > 510 - 55 - HOSTLEN - NICKLEN) {
config_error("%s:%i: set::network-icon URL is too long (max %d characters)",
cep->file->filename, cep->line_number, max_url_len);
errors++;