diff --git a/doc/reference.conf b/doc/reference.conf index f946871f..89fd68bc 100644 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -158,6 +158,7 @@ #loadmodule "extensions/m_sendbans"; #loadmodule "extensions/m_shedding"; #loadmodule "extensions/m_webirc"; +#loadmodule "extensions/network_icon"; #loadmodule "extensions/no_kill_services"; #loadmodule "extensions/no_locops"; #loadmodule "extensions/no_oper_invis"; @@ -1535,6 +1536,9 @@ general { * requires extensions/drain to be loaded. */ drain_reason = "This server is not accepting connections."; + + /* network_icon_url: add a URL to an icon representing the network. */ + #network_icon_url = "https://example.org/icon.png"; }; modules { diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 2b16d118..242ef062 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -57,6 +57,7 @@ extension_LTLIBRARIES = \ m_sendbans.la \ m_shedding.la \ m_webirc.la \ + network_icon.la \ no_kill_services.la \ no_locops.la \ no_oper_invis.la \ diff --git a/extensions/meson.build b/extensions/meson.build index 293d9719..1da1265e 100644 --- a/extensions/meson.build +++ b/extensions/meson.build @@ -50,6 +50,7 @@ extension_modules = [ 'm_sendbans', 'm_shedding', 'm_webirc', + 'network_icon', 'no_kill_services', 'no_locops', 'no_oper_invis', diff --git a/extensions/network_icon.c b/extensions/network_icon.c new file mode 100644 index 00000000..5027ec8b --- /dev/null +++ b/extensions/network_icon.c @@ -0,0 +1,71 @@ +/* + * Solanum: a slightly advanced ircd + * network_icon.c: Advertise a network icon. + * + * Copyright (C) 2026 internet-catte + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "stdinc.h" +#include "modules.h" +#include "newconf.h" +#include "supported.h" + +static const char network_icon_desc[] = "Provides the draft/ICON ISUPPORT token for clients that support showing a network icon"; + +static int modinit(void); +static void moddeinit(void); +static void network_icon_init_conf(void *data); +static void network_icon_conf_set_url(void *data); + +static char *network_icon_url = NULL; + +mapi_hfn_list_av1 network_icon_hfnlist[] = { + { "conf_read_start", network_icon_init_conf }, +}; + +DECLARE_MODULE_AV2(network_icon, modinit, moddeinit, NULL, NULL, network_icon_hfnlist, NULL, NULL, network_icon_desc); + +static int +modinit(void) +{ + add_conf_item("general", "network_icon_url", CF_QSTRING, network_icon_conf_set_url); + add_isupport("draft/ICON", isupport_stringptr, &network_icon_url); + return 0; +} + +static void +moddeinit(void) +{ + delete_isupport("draft/ICON"); + rb_free(network_icon_url); + remove_conf_item("general", "network_icon_url"); +} + +static void +network_icon_init_conf(void *data) +{ + rb_free(network_icon_url); + network_icon_url = NULL; +} + +static void +network_icon_conf_set_url(void *data) +{ + rb_free(network_icon_url); + network_icon_url = rb_strdup(data); +}