aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ed Kellett2020-10-12 20:29:18 +0100
committerGravatar Ed Kellett2020-10-17 02:49:05 +0100
commit83d5562f9c47e2a10b4930922f6f6255bcc9d1a0 (patch)
tree9a92f66a7f939bc6b4429b26723b1355cdce4e78
parentAdd match_client hook (diff)
downloadsolanum-edk/mask-hooks.tar.gz
solanum-edk/mask-hooks.tar.bz2
solanum-edk/mask-hooks.zip
Add extensions/match_gatewayip edk/mask-hooks
-rw-r--r--extensions/Makefile.am1
-rw-r--r--extensions/match_gatewayip.c53
2 files changed, 54 insertions, 0 deletions
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index cf44a370..e941260e 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -79,6 +79,7 @@ extension_LTLIBRARIES = \
spy_trace_notice.la \
drain.la \
identify_msg.la \
+ match_gatewayip.la \
example_module.la
if HAVE_HYPERSCAN
diff --git a/extensions/match_gatewayip.c b/extensions/match_gatewayip.c
new file mode 100644
index 00000000..b6199a5f
--- /dev/null
+++ b/extensions/match_gatewayip.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 Ed Kellett
+ *
+ * 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 <hook.h>
+#include <match.h>
+#include <channel.h>
+
+static const char match_gatewayip_desc[] = "Consider .../ip.X.X.X.X hostnames in channel IP ban matching";
+
+static void hook_match_client(void *);
+
+mapi_hfn_list_av1 match_gatewayip_hfnlist[] = {
+ { "match_client", hook_match_client },
+ { NULL, NULL }
+};
+
+void hook_match_client(void *data_)
+{
+ hook_data_match_client *data = data_;
+ const char *p;
+
+ if (data->mode_type != CHFL_BAN && data->mode_type != CHFL_QUIET)
+ return;
+
+ if (!IsDynSpoof(data->client))
+ return;
+
+ p = strstr(data->client->host, "/ip.");
+ if (p == NULL)
+ return;
+
+ matchset_append_ip(data->ms, "%s!%s@%s", data->client->name, data->client->username, p + 4);
+}
+
+DECLARE_MODULE_AV2(match_gatewayip, NULL, NULL, NULL, NULL, match_gatewayip_hfnlist, NULL, NULL, match_gatewayip_desc);