]> jfr.im git - solanum.git/commitdiff
Port m_invex_regonly from ircd-seven (#178)
authorMike Quin <redacted>
Sat, 12 Jun 2021 18:22:42 +0000 (19:22 +0100)
committerGitHub <redacted>
Sat, 12 Jun 2021 18:22:42 +0000 (11:22 -0700)
Port m_invex_regonly from ircd-seven

This module allows +I to be used to bypass +r (registered only) as
well as +i (invite only).

Co-authored-by: Doug Freed <redacted>
Co-authored-by: Ed Kellett <redacted>
extensions/Makefile.am
extensions/invex_regonly.c [new file with mode: 0644]

index 1d3bcda8a7344648401a1155f8200dc4fd60de9e..850650fa4cc7c6c3a51153f186325f26081c9c32 100644 (file)
@@ -68,6 +68,7 @@ extension_LTLIBRARIES =               \
   drain.la                     \
   identify_msg.la              \
   cap_realhost.la              \
+  invex_regonly.la             \
   example_module.la
 
 if HAVE_HYPERSCAN
diff --git a/extensions/invex_regonly.c b/extensions/invex_regonly.c
new file mode 100644 (file)
index 0000000..2cce04a
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * invex_regonly.c Allow invite exemptions to bypass registered-only (+r)
+ */
+#include "stdinc.h"
+#include "modules.h"
+#include "hook.h"
+#include "channel.h"
+#include "s_conf.h"
+#include "numeric.h"
+
+static void h_can_join(hook_data_channel *);
+
+mapi_hfn_list_av1 invex_regonly_hfnlist[] = {
+       { "can_join", (hookfn) h_can_join },
+       { NULL, NULL }
+};
+
+DECLARE_MODULE_AV1(invex_regonly, NULL, NULL, NULL, NULL, invex_regonly_hfnlist, "$Revision$");
+
+static void
+h_can_join(hook_data_channel *data)
+{
+       struct Client *source_p = data->client;
+       struct Channel *chptr = data->chptr;
+       struct Ban *invex = NULL;
+       struct matchset ms;
+       rb_dlink_node *ptr;
+       
+       if(data->approved != ERR_NEEDREGGEDNICK)
+               return;
+       if(!ConfigChannel.use_invex)
+               return;
+
+       matchset_for_client(source_p, &ms);
+
+       RB_DLINK_FOREACH(ptr, chptr->invexlist.head)
+       {
+               invex = ptr->data;
+               if (matches_mask(&ms, invex->banstr) ||
+                               match_extban(invex->banstr, source_p, chptr, CHFL_INVEX))
+               {
+                       data->approved = 0;
+                       break;
+               }
+       }
+}