4 * A server-side module for Citadel designed to filter idiots off the network.
6 * Copyright (c) 2002-2009 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <sys/types.h>
33 #if TIME_WITH_SYS_TIME
34 # include <sys/time.h>
38 # include <sys/time.h>
47 #include <libcitadel.h>
50 #include "citserver.h"
59 #include "serv_network.h" /* Needed for defenition of FilterList */
62 #include "ctdl_module.h"
66 * This handler detects whether an incoming network message is from some
67 * moron user who the site operator has elected to filter out. If a match
68 * is found, the message is rejected.
70 int filter_the_idiots(struct CtdlMessage *msg, char *target_room) {
76 if ( (msg == NULL) || (filterlist == NULL) ) {
80 for (fptr = filterlist; fptr != NULL; fptr = fptr->next) {
86 if (msg->cm_fields['A'] != NULL) {
87 if ( (!strcasecmp(msg->cm_fields['A'], fptr->fl_user))
88 || (fptr->fl_user[0] == 0) ) {
93 if (msg->cm_fields['C'] != NULL) {
94 if ( (!strcasecmp(msg->cm_fields['C'], fptr->fl_room))
95 || (fptr->fl_room[0] == 0) ) {
100 if (msg->cm_fields['O'] != NULL) {
101 if ( (!strcasecmp(msg->cm_fields['O'], fptr->fl_room))
102 || (fptr->fl_room[0] == 0) ) {
107 if (msg->cm_fields['N'] != NULL) {
108 if ( (!strcasecmp(msg->cm_fields['N'], fptr->fl_node))
109 || (fptr->fl_node[0] == 0) ) {
114 if (zap_user + zap_room + zap_node == 3) return(1);
122 CTDL_MODULE_INIT(netfilter)
126 CtdlRegisterNetprocHook(filter_the_idiots);
129 /* return our Subversion id for the Log */