2 * A server-side module for Citadel designed to filter idiots off the network.
4 * Copyright (c) 2002-2009 by the citadel.org team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <sys/types.h>
31 #if TIME_WITH_SYS_TIME
32 # include <sys/time.h>
36 # include <sys/time.h>
45 #include <libcitadel.h>
48 #include "citserver.h"
55 #include "serv_network.h" /* Needed for defenition of FilterList */
58 #include "ctdl_module.h"
62 * This handler detects whether an incoming network message is from some
63 * moron user who the site operator has elected to filter out. If a match
64 * is found, the message is rejected.
66 int filter_the_idiots(struct CtdlMessage *msg, char *target_room) {
72 if ( (msg == NULL) || (filterlist == NULL) ) {
76 for (fptr = filterlist; fptr != NULL; fptr = fptr->next) {
82 if (msg->cm_fields['A'] != NULL) {
83 if ( (!strcasecmp(msg->cm_fields['A'], fptr->fl_user))
84 || (fptr->fl_user[0] == 0) ) {
89 if (msg->cm_fields['C'] != NULL) {
90 if ( (!strcasecmp(msg->cm_fields['C'], fptr->fl_room))
91 || (fptr->fl_room[0] == 0) ) {
96 if (msg->cm_fields['O'] != NULL) {
97 if ( (!strcasecmp(msg->cm_fields['O'], fptr->fl_room))
98 || (fptr->fl_room[0] == 0) ) {
103 if (msg->cm_fields['N'] != NULL) {
104 if ( (!strcasecmp(msg->cm_fields['N'], fptr->fl_node))
105 || (fptr->fl_node[0] == 0) ) {
110 if (zap_user + zap_room + zap_node == 3) return(1);
118 CTDL_MODULE_INIT(netfilter)
122 CtdlRegisterNetprocHook(filter_the_idiots);
125 /* return our Subversion id for the Log */