]>
Commit | Line | Data |
---|---|---|
63c95a47 | 1 | /* spamserv.h - anti spam service |
2 | * Copyright 2004 feigling | |
3 | * | |
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 | |
348683aa | 6 | * the Free Software Foundation; either version 3 of the License, or |
63c95a47 | 7 | * (at your option) any later version. Important limitations are |
8 | * listed in the COPYING file that accompanies this software. | |
9 | * | |
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. | |
14 | * | |
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. | |
17 | * | |
18 | * $Id$ | |
19 | */ | |
20 | ||
21 | #ifndef _spamserv_h | |
22 | #define _spamserv_h | |
23 | ||
bc436744 | 24 | #include "chanserv.h" |
25 | ||
63c95a47 | 26 | #ifdef HAVE_ARPA_INET_H |
27 | #include <arpa/inet.h> | |
28 | #endif | |
29 | ||
30 | /***********************************************/ | |
31 | /* Channel */ | |
32 | /***********************************************/ | |
33 | ||
34 | enum channelinfo | |
35 | { | |
36 | ci_SpamLimit = 0, | |
c9ec8867 | 37 | ci_AdvReaction = 1, |
38 | ci_WarnReaction = 2, | |
a674c5d3 | 39 | ci_BadReaction = 3, |
c9ec8867 | 40 | ci_CapsReaction = 4, |
63c95a47 | 41 | ci_Max |
42 | }; | |
43 | ||
44 | #define CHAN_INFO_SIZE (ci_Max + 1) | |
c9ec8867 | 45 | #define CHAN_INFO_DEFAULT "blssss" |
63c95a47 | 46 | |
47 | #define CHAN_SPAMSCAN 0x00000001 | |
48 | #define CHAN_CHANFLOODSCAN 0x00000002 | |
49 | #define CHAN_JOINFLOOD 0x00000004 | |
50 | #define CHAN_ADV_SCAN 0x00000008 | |
c9ec8867 | 51 | #define CHAN_SUSPENDED 0x00000010 |
52 | #define CHAN_BADWORDSCAN 0x00000020 | |
53 | #define CHAN_CAPSSCAN 0x00000040 | |
63c95a47 | 54 | |
55 | #define CHAN_FLAGS_DEFAULT (CHAN_SPAMSCAN | CHAN_CHANFLOODSCAN | CHAN_JOINFLOOD) | |
56 | ||
57 | #define CHECK_SPAM(x) ((x)->flags & CHAN_SPAMSCAN) | |
58 | #define CHECK_FLOOD(x) ((x)->flags & CHAN_CHANFLOODSCAN) | |
59 | #define CHECK_JOINFLOOD(x) ((x)->flags & CHAN_JOINFLOOD) | |
60 | #define CHECK_ADV(x) ((x)->flags & CHAN_ADV_SCAN) | |
63c95a47 | 61 | #define CHECK_SUSPENDED(x) ((x)->flags & CHAN_SUSPENDED) |
62 | #define CHECK_BADWORDSCAN(x) ((x)->flags & CHAN_BADWORDSCAN) | |
a674c5d3 | 63 | #define CHECK_CAPSSCAN(x) ((x)->flags & CHAN_CAPSSCAN) |
63c95a47 | 64 | |
65 | struct chanInfo | |
66 | { | |
67 | struct chanNode *channel; | |
68 | struct string_list *exceptions; | |
69 | struct string_list *badwords; | |
bc436744 | 70 | unsigned int exceptlevel; |
2e4e27fe | 71 | unsigned int exceptadvlevel; |
72 | unsigned int exceptbadwordlevel; | |
a674c5d3 | 73 | unsigned int exceptcapslevel; |
2e4e27fe | 74 | unsigned int exceptfloodlevel; |
75 | unsigned int exceptspamlevel; | |
63c95a47 | 76 | unsigned int flags : 30; |
a674c5d3 | 77 | int capsmin; |
78 | int capspercent; | |
79 | char info[CHAN_INFO_SIZE+1]; | |
63c95a47 | 80 | time_t suspend_expiry; |
81 | }; | |
82 | ||
83 | /***********************************************/ | |
84 | /* User */ | |
85 | /***********************************************/ | |
86 | ||
87 | #define USER_KICK 0x00000001 | |
88 | #define USER_KICKBAN 0x00000002 | |
89 | #define USER_SHORT_TBAN 0x00000004 | |
90 | #define USER_LONG_TBAN 0x00000008 | |
91 | #define USER_KILL 0x00000010 | |
92 | #define USER_GLINE 0x00000020 | |
93 | #define USER_WARNED 0x00000040 | |
94 | #define USER_KILLED 0x00000080 | |
95 | #define USER_ADV_WARNED 0x00000100 | |
96 | #define USER_BAD_WARNED 0x00000200 | |
a674c5d3 | 97 | #define USER_CAPS_WARNED 0x00000400 |
63c95a47 | 98 | |
99 | #define CHECK_KICK(x) ((x)->flags & USER_KICK) | |
100 | #define CHECK_KICKBAN(x) ((x)->flags & USER_KICKBAN) | |
101 | #define CHECK_SHORT_TBAN(x) ((x)->flags & USER_SHORT_TBAN) | |
102 | #define CHECK_LONG_TBAN(x) ((x)->flags & USER_LONG_TBAN) | |
103 | #define CHECK_KILL(x) ((x)->flags & USER_KILL) | |
104 | #define CHECK_GLINE(x) ((x)->flags & USER_GLINE) | |
105 | #define CHECK_WARNED(x) ((x)->flags & USER_WARNED) | |
106 | #define CHECK_KILLED(x) ((x)->flags & USER_KILLED) | |
107 | #define CHECK_ADV_WARNED(x) ((x)->flags & USER_ADV_WARNED) | |
108 | #define CHECK_BAD_WARNED(x) ((x)->flags & USER_BAD_WARNED) | |
a674c5d3 | 109 | #define CHECK_CAPS_WARNED(x) ((x)->flags & USER_CAPS_WARNED) |
63c95a47 | 110 | |
111 | #define SPAM_WARNLEVEL 1 | |
112 | ||
113 | #define FLOOD_TIMEQ_FREQ 5 | |
114 | #define FLOOD_EXPIRE 5 | |
115 | #define FLOOD_WARNLEVEL 1 | |
116 | #define FLOOD_MAX_LINES 8 | |
117 | ||
118 | #define JOINFLOOD_TIMEQ_FREQ 225 | |
119 | #define JOINFLOOD_EXPIRE 450 | |
120 | #define JOINFLOOD_MAX 3 | |
121 | #define JOINFLOOD_B_DURATION 900 | |
122 | ||
123 | #define ADV_TIMEQ_FREQ 300 | |
124 | #define ADV_EXPIRE 900 | |
125 | #define ADV_WARNLEVEL 2 | |
126 | ||
127 | #define BAD_TIMEQ_FREQ 300 | |
128 | #define BAD_EXPIRE 900 | |
129 | #define BAD_WARNLEVEL 2 | |
130 | ||
a674c5d3 | 131 | #define CAPS_TIMEQ_FREQ 300 |
132 | #define CAPS_EXPIRE 900 | |
133 | #define CAPS_WARNLEVEL 2 | |
134 | ||
63c95a47 | 135 | #define WARNLEVEL_TIMEQ_FREQ 1800 |
136 | #define MAX_WARNLEVEL 6 | |
137 | ||
138 | #define KILL_TIMEQ_FREQ 450 | |
139 | #define KILL_EXPIRE 1800 | |
140 | #define KILL_WARNLEVEL 3 | |
141 | ||
142 | struct spamNode | |
143 | { | |
144 | struct chanNode *channel; | |
145 | unsigned long crc32; | |
146 | unsigned int count; | |
147 | struct spamNode *prev; | |
148 | struct spamNode *next; | |
149 | }; | |
150 | ||
151 | struct floodNode | |
152 | { | |
153 | struct chanNode *channel; | |
154 | struct userNode *owner; | |
155 | unsigned int count; | |
156 | time_t time; | |
157 | struct floodNode *prev; | |
158 | struct floodNode *next; | |
159 | }; | |
160 | ||
161 | struct killNode | |
162 | { | |
163 | unsigned int warnlevel; | |
164 | time_t time; | |
165 | }; | |
166 | ||
167 | struct userInfo | |
168 | { | |
169 | struct userNode *user; | |
170 | struct spamNode *spam; | |
171 | struct floodNode *flood; | |
172 | struct floodNode *joinflood; | |
173 | unsigned int flags : 30; | |
174 | unsigned int warnlevel; | |
175 | time_t lastadv; | |
176 | time_t lastbad; | |
a674c5d3 | 177 | time_t lastcaps; |
63c95a47 | 178 | }; |
179 | ||
180 | /***********************************************/ | |
181 | /* Other Stuff */ | |
182 | /***********************************************/ | |
183 | ||
184 | enum cs_unreg | |
185 | { | |
186 | manually, | |
187 | expire, | |
188 | lost_all_users | |
189 | }; | |
190 | ||
191 | void init_spamserv(const char *nick); | |
192 | struct chanInfo *get_chanInfo(const char *channelname); | |
193 | void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text); | |
194 | void spamserv_cs_suspend(struct chanNode *channel, time_t expiry, int suspend, char *reason); | |
195 | int spamserv_cs_move_merge(struct userNode *user, struct chanNode *channel, struct chanNode *target, int move); | |
196 | void spamserv_cs_unregister(struct userNode *user, struct chanNode *channel, enum cs_unreg type, char *reason); | |
197 | ||
198 | #endif |