1 /* bot_NeonSpam.h - NeonServ v5.3
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
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 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef _bot_NeonSpam_h
19 #define _bot_NeonSpam_h
24 #define SPAMSETTINGS_SPAMSCAN 0x000001
25 #define SPAMSETTINGS_SPAMSCAN_OPS 0x000002
26 #define SPAMSETTINGS_SPAMSCAN_VOICE 0x000004
27 #define SPAMSETTINGS_SPAMCHARS "abc"
28 #define SPAMSETTINGS_SPAMEXCINDEX 0
31 #define SPAMSETTINGS_FLOODSCAN 0x000008
32 #define SPAMSETTINGS_FLOODSCAN_OPS 0x000010
33 #define SPAMSETTINGS_FLOODSCAN_VOICE 0x000020
34 #define SPAMSETTINGS_FLOODCHARS "def"
35 #define SPAMSETTINGS_FLOODEXCINDEX 1
36 #define SPAMSETTINGS_FLOODSENINDEX 0
39 #define SPAMSETTINGS_JOINSCAN 0x000040
40 #define SPAMSETTINGS_JOINSCAN_OPS 0x000080
41 #define SPAMSETTINGS_JOINSCAN_VOICE 0x000100
42 #define SPAMSETTINGS_JOINCHARS "ghi"
43 #define SPAMSETTINGS_JOINEXCINDEX 2
44 #define SPAMSETTINGS_JOINSENINDEX 1
47 #define SPAMSETTINGS_BOTNETSCAN 0x000200
48 #define SPAMSETTINGS_BOTNETSCAN_OPS 0x000400
49 #define SPAMSETTINGS_BOTNETSCAN_VOICE 0x000800
50 #define SPAMSETTINGS_BOTNETSCAN_STRIPCC 0x001000
51 #define SPAMSETTINGS_BOTNETCHARS "jklm"
52 #define SPAMSETTINGS_BOTNETEXCINDEX 3
55 #define SPAMSETTINGS_CAPSSCAN 0x002000
56 #define SPAMSETTINGS_CAPSSCAN_OPS 0x004000
57 #define SPAMSETTINGS_CAPSSCAN_VOICE 0x008000
58 #define SPAMSETTINGS_CAPSCHARS "nop"
59 #define SPAMSETTINGS_CAPSEXCINDEX 4
60 #define SPAMSETTINGS_CAPSPERCENTINDEX 0
63 #define SPAMSETTINGS_DIGITSCAN 0x010000
64 #define SPAMSETTINGS_DIGITSCAN_OPS 0x020000
65 #define SPAMSETTINGS_DIGITSCAN_VOICE 0x040000
66 #define SPAMSETTINGS_DIGITCHARS "qrs"
67 #define SPAMSETTINGS_DIGITEXCINDEX 5
68 #define SPAMSETTINGS_DIGITPERCENTINDEX 1
71 #define SPAMSETTINGS_CHARS SPAMSETTINGS_SPAMCHARS SPAMSETTINGS_FLOODCHARS SPAMSETTINGS_JOINCHARS SPAMSETTINGS_BOTNETCHARS SPAMSETTINGS_CAPSCHARS SPAMSETTINGS_DIGITCHARS
72 #define SPAMSETTINGS_FLAGS 0x07ffff /* all flags that can be stored in the database */
73 #define SPAMSETTINGS_EXCEPTINDEXES 6
74 #define SPAMSETTINGS_SENSIBILITYINDEXES 2
75 #define SPAMSETTINGS_PERCENTINDEXES 2
78 #define SPAMSETTINGS_KICKEDBOTQUEUE 0x080000
79 #define SPAMSETTINGS_ISTIMEBAN 0x100000
80 #define SPAMSETTINGS_SETTIMEBAN 0x200000
82 #define MAX_FLOOD_AMOUNT 300
83 #define MIN_FLOOD_AMOUNT 2
84 #define MAX_FLOOD_TIME 200
86 #define MAX_JOIN_AMOUNT 300
87 #define MIN_JOIN_AMOUNT 2
88 #define MAX_JOIN_TIME 200
90 #define BOTNETSCAN_USERS 4
91 #define BOTNETSCAN_TIME 2
93 struct NeonSpamSettings {
95 unsigned char spam_amount;
96 unsigned char sensibility_amount[SPAMSETTINGS_SENSIBILITYINDEXES];
97 unsigned char sensibility_time[SPAMSETTINGS_SENSIBILITYINDEXES];
98 unsigned int exceptlevel[SPAMSETTINGS_EXCEPTINDEXES];
99 unsigned char percent[SPAMSETTINGS_PERCENTINDEXES];
102 struct NeonSpamJoinNode *join_nodes;
105 unsigned long lastmsg; //crc32 hash
107 char *botnicks[BOTNETSCAN_USERS];
112 * user gets MAX_FLOOD_TIME points per message
113 * points get removed each loop
114 * pounts to be removed each second:
115 * MAX_FLOOD_TIME/flood_time
117 * the floodlimit is reached, if the penalty points
118 * are bigger than MAX_FLOOD_TIME * flood_amount
121 #define NEONSPAMNODE_FLAG_CAPSSCAN_WARNED 0x01
122 #define NEONSPAMNODE_FLAG_DIGITSCAN_WARNED 0x02
124 struct NeonSpamNode {
125 unsigned long lastmsg; //crc32 hash
126 unsigned char spamcount;
128 time_t last_penalty_update;
132 struct NeonSpamJoinNode {
136 time_t last_penalty_update;
137 struct NeonSpamJoinNode *next;
140 void init_NeonSpam();
141 void loop_NeonSpam();
142 void free_NeonSpam();
144 void freeNeonSpamSettings(struct NeonSpamSettings *settings);
145 char* convertNeonSpamSettingsToString(unsigned int flags, char *buffer);