1 /* spamserv.h - anti spam service
2 * Copyright 2004 feigling
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. Important limitations are
8 * listed in the COPYING file that accompanies this software.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, email srvx-maintainers@srvx.net.
18 * $Id: spamserv.h,v 1.3 2004/06/27 22:20:00 feigling Exp $
24 #ifdef HAVE_ARPA_INET_H
25 #include <arpa/inet.h>
28 /***********************************************/
30 /***********************************************/
40 #define CHAN_INFO_SIZE (ci_Max + 1)
41 #define CHAN_INFO_DEFAULT "bls"
43 #define CHAN_SPAMSCAN 0x00000001
44 #define CHAN_FLOODSCAN 0x00000002
45 #define CHAN_JOINFLOOD 0x00000004
46 #define CHAN_ADV_SCAN 0x00000008
47 #define CHAN_SCAN_CHANOPS 0x00000010
48 #define CHAN_SCAN_VOICED 0x00000020
49 #define CHAN_SUSPENDED 0x00000040
51 #define CHAN_FLAGS_DEFAULT (CHAN_SPAMSCAN | CHAN_FLOODSCAN | CHAN_JOINFLOOD)
53 #define CHECK_SPAM(x) ((x)->flags & CHAN_SPAMSCAN)
54 #define CHECK_FLOOD(x) ((x)->flags & CHAN_FLOODSCAN)
55 #define CHECK_JOINFLOOD(x) ((x)->flags & CHAN_JOINFLOOD)
56 #define CHECK_ADV(x) ((x)->flags & CHAN_ADV_SCAN)
57 #define CHECK_CHANOPS(x) ((x)->flags & CHAN_SCAN_CHANOPS)
58 #define CHECK_VOICED(x) ((x)->flags & CHAN_SCAN_VOICED)
59 #define CHECK_SUSPENDED(x) ((x)->flags & CHAN_SUSPENDED)
63 struct chanNode *channel;
64 struct string_list *exceptions;
65 unsigned int flags : 30;
66 unsigned int exceptlevel;
67 char info[CHAN_INFO_SIZE];
68 unsigned long suspend_expiry;
71 /***********************************************/
73 /***********************************************/
75 #define USER_KICK 0x00000001
76 #define USER_KICKBAN 0x00000002
77 #define USER_SHORT_TBAN 0x00000004
78 #define USER_LONG_TBAN 0x00000008
79 #define USER_KILL 0x00000010
80 #define USER_GLINE 0x00000020
81 #define USER_WARNED 0x00000040
82 #define USER_KILLED 0x00000080
83 #define USER_ADV_WARNED 0x00000100
85 #define CHECK_KICK(x) ((x)->flags & USER_KICK)
86 #define CHECK_KICKBAN(x) ((x)->flags & USER_KICKBAN)
87 #define CHECK_SHORT_TBAN(x) ((x)->flags & USER_SHORT_TBAN)
88 #define CHECK_LONG_TBAN(x) ((x)->flags & USER_LONG_TBAN)
89 #define CHECK_KILL(x) ((x)->flags & USER_KILL)
90 #define CHECK_GLINE(x) ((x)->flags & USER_GLINE)
91 #define CHECK_WARNED(x) ((x)->flags & USER_WARNED)
92 #define CHECK_KILLED(x) ((x)->flags & USER_KILLED)
93 #define CHECK_ADV_WARNED(x) ((x)->flags & USER_ADV_WARNED)
95 #define SPAM_WARNLEVEL 1
97 #define FLOOD_TIMEQ_FREQ 5
98 #define FLOOD_EXPIRE 5
99 #define FLOOD_WARNLEVEL 1
100 #define FLOOD_MAX_LINES 8
102 #define JOINFLOOD_TIMEQ_FREQ 225
103 #define JOINFLOOD_EXPIRE 450
104 #define JOINFLOOD_MAX 3
105 #define JOINFLOOD_B_DURATION 900
107 #define ADV_TIMEQ_FREQ 300
108 #define ADV_EXPIRE 900
109 #define ADV_WARNLEVEL 2
111 #define WARNLEVEL_TIMEQ_FREQ 1800
112 #define MAX_WARNLEVEL 6
114 #define KILL_TIMEQ_FREQ 450
115 #define KILL_EXPIRE 1800
116 #define KILL_WARNLEVEL 3
120 struct chanNode *channel;
123 struct spamNode *prev;
124 struct spamNode *next;
129 struct chanNode *channel;
130 struct userNode *owner;
133 struct floodNode *prev;
134 struct floodNode *next;
139 unsigned int warnlevel;
145 struct userNode *user;
146 struct spamNode *spam;
147 struct floodNode *flood;
148 struct floodNode *joinflood;
149 unsigned int flags : 30;
150 unsigned int warnlevel;
154 /***********************************************/
156 /***********************************************/
165 void init_spamserv(const char *nick);
166 struct chanInfo *get_chanInfo(const char *channelname);
167 void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text);
168 void spamserv_cs_suspend(struct chanNode *channel, time_t expiry, int suspend, char *reason);
169 int spamserv_cs_move_merge(struct userNode *user, struct chanNode *channel, struct chanNode *target, int move);
170 void spamserv_cs_unregister(struct userNode *user, struct chanNode *channel, enum cs_unreg type, char *reason);