diff --git a/Makefile.windows b/Makefile.windows index 5a60a34e2..5f1f1ca83 100644 --- a/Makefile.windows +++ b/Makefile.windows @@ -323,6 +323,7 @@ DLL_FILES=\ src/modules/names.dll \ src/modules/netinfo.dll \ src/modules/nick.dll \ + src/modules/no-implicit-names.dll \ src/modules/nocodes.dll \ src/modules/cloak_md5.dll \ src/modules/cloak_none.dll \ @@ -1078,6 +1079,9 @@ src/modules/netinfo.dll: src/modules/netinfo.c $(INCLUDES) src/modules/nick.dll: src/modules/nick.c $(INCLUDES) $(CC) $(MODCFLAGS) src/modules/nick.c /Fesrc/modules/ /Fosrc/modules/ /Fdsrc/modules/nick.pdb $(MODLFLAGS) +src/modules/no-implicit-names.dll: src/modules/no-implicit-names.c $(INCLUDES) + $(CC) $(MODCFLAGS) src/modules/no-implicit-names.c /Fesrc/modules/ /Fosrc/modules/ /Fdsrc/modules/no-implicit-names.pdb $(MODLFLAGS) + src/modules/nocodes.dll: src/modules/nocodes.c $(INCLUDES) $(CC) $(MODCFLAGS) src/modules/nocodes.c /Fesrc/modules/ /Fosrc/modules/ /Fdsrc/modules/nocodes.pdb $(MODLFLAGS) diff --git a/doc/conf/modules.default.conf b/doc/conf/modules.default.conf index cc3671b93..a873bd194 100644 --- a/doc/conf/modules.default.conf +++ b/doc/conf/modules.default.conf @@ -244,6 +244,7 @@ loadmodule "chathistory"; /* CHATHISTORY client command, 005 and a CAP (draft) * loadmodule "monitor"; /* MONITOR command with functionality similar to WATCH */ loadmodule "extended-monitor"; /* add away status, gecos and userhost changes to MONITOR (draft) */ loadmodule "standard-replies"; /* Standard Replies */ +loadmodule "no-implicit-names"; /* Opt out of receiving implicit NAMES when joining a channel */ /*** RPC modules *** diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in index be1d2767e..1428776a9 100644 --- a/src/modules/Makefile.in +++ b/src/modules/Makefile.in @@ -85,6 +85,7 @@ MODULES= \ real-quit-reason.so \ spamreport.so crule.so \ central-api.so central-blocklist.so \ + no-implicit-names.so \ $(GEOIP_CLASSIC_OBJECTS) $(GEOIP_MAXMIND_OBJECTS) MODULEFLAGS=@MODULEFLAGS@ diff --git a/src/modules/join.c b/src/modules/join.c index 7ce6f5812..3da22183a 100644 --- a/src/modules/join.c +++ b/src/modules/join.c @@ -270,7 +270,8 @@ void _join_channel(Channel *channel, Client *client, MessageTag *recv_mtags, con parv[0] = NULL; parv[1] = channel->name; parv[2] = NULL; - do_cmd(client, NULL, "NAMES", 2, parv); + if (!HasCapability(client,"draft/no-implicit-names") && !HasCapability(client, "no-implicit-names")) + do_cmd(client, NULL, "NAMES", 2, parv);; unreal_log(ULOG_INFO, "join", "LOCAL_CLIENT_JOIN", client, "User $client joined $channel", diff --git a/src/modules/no-implicit-names.c b/src/modules/no-implicit-names.c new file mode 100644 index 000000000..56997392d --- /dev/null +++ b/src/modules/no-implicit-names.c @@ -0,0 +1,67 @@ +/* + * Unreal Internet Relay Chat Daemon, src/modules/no-implicit-names.c + * (C) 2023 Valware and the UnrealIRCd Team + * + * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "unrealircd.h" + +ModuleHeader MOD_HEADER + = { + "no-implicit-names", + "1.0", + "Opt out of receiving an implicit NAMES list on JOIN", + "UnrealIRCd Team", + "unrealircd-6", +}; + +#define NO_IMPLICIT_NAMES_CAP_DRAFT "draft/no-implicit-names" +#define NO_IMPLICIT_NAMES_CAP "no-implicit-names" + +long CAP_NO_IMPLICIT_NAMES_DRAFT = 0L; +long CAP_NO_IMPLICIT_NAMES = 0L; + +MOD_INIT() +{ + /** We only add the draft version for now */ + ClientCapabilityInfo cap; + memset(&cap, 0, sizeof(cap)); + cap.name = NO_IMPLICIT_NAMES_CAP_DRAFT; + if (!ClientCapabilityAdd(modinfo->handle, &cap, &CAP_NO_IMPLICIT_NAMES_DRAFT)) + { + return MOD_FAILED; + } + + /** This is for the future :D */ + /** + memset(&cap, 0, sizeof(cap)); + cap.name = NO_IMPLICIT_NAMES_CAP; + ClientCapabilityAdd(modinfo->handle, &cap, &CAP_NO_IMPLICIT_NAMES); + */ + + return MOD_SUCCESS; +} + +MOD_LOAD() +{ + return MOD_SUCCESS; +} + +MOD_UNLOAD() +{ + return MOD_SUCCESS; +} +