]> jfr.im git - irc/evilnet/x3.git/blame - src/spamserv.h
improve stats routing command
[irc/evilnet/x3.git] / src / spamserv.h
CommitLineData
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
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.
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
24#ifdef HAVE_ARPA_INET_H
25#include <arpa/inet.h>
26#endif
27
28/***********************************************/
29/* Channel */
30/***********************************************/
31
32enum channelinfo
33{
34 ci_SpamLimit = 0,
35 ci_AdvReaction,
36 ci_WarnReaction,
37 ci_BadReaction,
38 ci_Max
39};
40
41#define CHAN_INFO_SIZE (ci_Max + 1)
42#define CHAN_INFO_DEFAULT "blss"
43
44#define CHAN_SPAMSCAN 0x00000001
45#define CHAN_CHANFLOODSCAN 0x00000002
46#define CHAN_JOINFLOOD 0x00000004
47#define CHAN_ADV_SCAN 0x00000008
48#define CHAN_SCAN_CHANOPS 0x00000010
49#define CHAN_SCAN_HALFOPS 0x00000020
50#define CHAN_SCAN_VOICED 0x00000040
51#define CHAN_SUSPENDED 0x00000080
52#define CHAN_BADWORDSCAN 0x00000100
53
54#define CHAN_FLAGS_DEFAULT (CHAN_SPAMSCAN | CHAN_CHANFLOODSCAN | CHAN_JOINFLOOD)
55
56#define CHECK_SPAM(x) ((x)->flags & CHAN_SPAMSCAN)
57#define CHECK_FLOOD(x) ((x)->flags & CHAN_CHANFLOODSCAN)
58#define CHECK_JOINFLOOD(x) ((x)->flags & CHAN_JOINFLOOD)
59#define CHECK_ADV(x) ((x)->flags & CHAN_ADV_SCAN)
60#define CHECK_CHANOPS(x) ((x)->flags & CHAN_SCAN_CHANOPS)
61#define CHECK_HALFOPS(x) ((x)->flags & CHAN_SCAN_HALFOPS)
62#define CHECK_VOICED(x) ((x)->flags & CHAN_SCAN_VOICED)
63#define CHECK_SUSPENDED(x) ((x)->flags & CHAN_SUSPENDED)
64#define CHECK_BADWORDSCAN(x) ((x)->flags & CHAN_BADWORDSCAN)
65
66struct chanInfo
67{
68 struct chanNode *channel;
69 struct string_list *exceptions;
70 struct string_list *badwords;
71 unsigned int flags : 30;
72 char info[CHAN_INFO_SIZE];
73 time_t suspend_expiry;
74};
75
76/***********************************************/
77/* User */
78/***********************************************/
79
80#define USER_KICK 0x00000001
81#define USER_KICKBAN 0x00000002
82#define USER_SHORT_TBAN 0x00000004
83#define USER_LONG_TBAN 0x00000008
84#define USER_KILL 0x00000010
85#define USER_GLINE 0x00000020
86#define USER_WARNED 0x00000040
87#define USER_KILLED 0x00000080
88#define USER_ADV_WARNED 0x00000100
89#define USER_BAD_WARNED 0x00000200
90
91#define CHECK_KICK(x) ((x)->flags & USER_KICK)
92#define CHECK_KICKBAN(x) ((x)->flags & USER_KICKBAN)
93#define CHECK_SHORT_TBAN(x) ((x)->flags & USER_SHORT_TBAN)
94#define CHECK_LONG_TBAN(x) ((x)->flags & USER_LONG_TBAN)
95#define CHECK_KILL(x) ((x)->flags & USER_KILL)
96#define CHECK_GLINE(x) ((x)->flags & USER_GLINE)
97#define CHECK_WARNED(x) ((x)->flags & USER_WARNED)
98#define CHECK_KILLED(x) ((x)->flags & USER_KILLED)
99#define CHECK_ADV_WARNED(x) ((x)->flags & USER_ADV_WARNED)
100#define CHECK_BAD_WARNED(x) ((x)->flags & USER_BAD_WARNED)
101
102#define SPAM_WARNLEVEL 1
103
104#define FLOOD_TIMEQ_FREQ 5
105#define FLOOD_EXPIRE 5
106#define FLOOD_WARNLEVEL 1
107#define FLOOD_MAX_LINES 8
108
109#define JOINFLOOD_TIMEQ_FREQ 225
110#define JOINFLOOD_EXPIRE 450
111#define JOINFLOOD_MAX 3
112#define JOINFLOOD_B_DURATION 900
113
114#define ADV_TIMEQ_FREQ 300
115#define ADV_EXPIRE 900
116#define ADV_WARNLEVEL 2
117
118#define BAD_TIMEQ_FREQ 300
119#define BAD_EXPIRE 900
120#define BAD_WARNLEVEL 2
121
122#define WARNLEVEL_TIMEQ_FREQ 1800
123#define MAX_WARNLEVEL 6
124
125#define KILL_TIMEQ_FREQ 450
126#define KILL_EXPIRE 1800
127#define KILL_WARNLEVEL 3
128
129struct spamNode
130{
131 struct chanNode *channel;
132 unsigned long crc32;
133 unsigned int count;
134 struct spamNode *prev;
135 struct spamNode *next;
136};
137
138struct floodNode
139{
140 struct chanNode *channel;
141 struct userNode *owner;
142 unsigned int count;
143 time_t time;
144 struct floodNode *prev;
145 struct floodNode *next;
146};
147
148struct killNode
149{
150 unsigned int warnlevel;
151 time_t time;
152};
153
154struct userInfo
155{
156 struct userNode *user;
157 struct spamNode *spam;
158 struct floodNode *flood;
159 struct floodNode *joinflood;
160 unsigned int flags : 30;
161 unsigned int warnlevel;
162 time_t lastadv;
163 time_t lastbad;
164};
165
166/***********************************************/
167/* Other Stuff */
168/***********************************************/
169
170enum cs_unreg
171{
172 manually,
173 expire,
174 lost_all_users
175};
176
177void init_spamserv(const char *nick);
178struct chanInfo *get_chanInfo(const char *channelname);
179void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text);
180void spamserv_cs_suspend(struct chanNode *channel, time_t expiry, int suspend, char *reason);
181int spamserv_cs_move_merge(struct userNode *user, struct chanNode *channel, struct chanNode *target, int move);
182void spamserv_cs_unregister(struct userNode *user, struct chanNode *channel, enum cs_unreg type, char *reason);
183
184#endif