-/* spamserv.h - anti spam service\r
- * Copyright 2004 feigling\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version. Important limitations are\r
- * listed in the COPYING file that accompanies this software.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, email srvx-maintainers@srvx.net.\r
- *\r
- * $Id: spamserv.h,v 1.3 2004/06/27 22:20:00 feigling Exp $\r
- */\r
-\r
-#ifndef _spamserv_h\r
-#define _spamserv_h\r
-\r
-#ifdef HAVE_ARPA_INET_H\r
-#include <arpa/inet.h>\r
-#endif\r
-\r
-/***********************************************/\r
-/* Channel */\r
-/***********************************************/\r
-\r
-enum channelinfo\r
-{\r
- ci_SpamLimit = 0,\r
- ci_AdvReaction,\r
- ci_WarnReaction,\r
- ci_Max\r
-};\r
-\r
-#define CHAN_INFO_SIZE (ci_Max + 1)\r
-#define CHAN_INFO_DEFAULT "bls"\r
-\r
-#define CHAN_SPAMSCAN 0x00000001\r
-#define CHAN_FLOODSCAN 0x00000002\r
-#define CHAN_JOINFLOOD 0x00000004\r
-#define CHAN_ADV_SCAN 0x00000008\r
-#define CHAN_SCAN_CHANOPS 0x00000010\r
-#define CHAN_SCAN_VOICED 0x00000020\r
-#define CHAN_SUSPENDED 0x00000040\r
-\r
-#define CHAN_FLAGS_DEFAULT (CHAN_SPAMSCAN | CHAN_FLOODSCAN | CHAN_JOINFLOOD)\r
-\r
-#define CHECK_SPAM(x) ((x)->flags & CHAN_SPAMSCAN)\r
-#define CHECK_FLOOD(x) ((x)->flags & CHAN_FLOODSCAN)\r
-#define CHECK_JOINFLOOD(x) ((x)->flags & CHAN_JOINFLOOD)\r
-#define CHECK_ADV(x) ((x)->flags & CHAN_ADV_SCAN)\r
-#define CHECK_CHANOPS(x) ((x)->flags & CHAN_SCAN_CHANOPS)\r
-#define CHECK_VOICED(x) ((x)->flags & CHAN_SCAN_VOICED)\r
-#define CHECK_SUSPENDED(x) ((x)->flags & CHAN_SUSPENDED)\r
-\r
-#define BADACTION_KICK 0\r
-#define BADACTION_BAN 1\r
-#define BADACTION_KILL 2\r
-#define BADACTION_GLINE 3\r
-\r
-struct chanInfo\r
-{\r
- struct chanNode *channel;\r
- struct string_list *exceptions;\r
- dict_t badwords;\r
- unsigned int flags : 30;\r
- unsigned int exceptlevel;\r
- char info[CHAN_INFO_SIZE];\r
- unsigned long suspend_expiry;\r
- unsigned int last_badword_id;\r
-};\r
-\r
-/***********************************************/\r
-/* User */\r
-/***********************************************/\r
-\r
-#define USER_KICK 0x00000001\r
-#define USER_KICKBAN 0x00000002\r
-#define USER_SHORT_TBAN 0x00000004\r
-#define USER_LONG_TBAN 0x00000008\r
-#define USER_KILL 0x00000010\r
-#define USER_GLINE 0x00000020\r
-#define USER_WARNED 0x00000040\r
-#define USER_KILLED 0x00000080\r
-#define USER_ADV_WARNED 0x00000100\r
-\r
-#define CHECK_KICK(x) ((x)->flags & USER_KICK)\r
-#define CHECK_KICKBAN(x) ((x)->flags & USER_KICKBAN)\r
-#define CHECK_SHORT_TBAN(x) ((x)->flags & USER_SHORT_TBAN)\r
-#define CHECK_LONG_TBAN(x) ((x)->flags & USER_LONG_TBAN)\r
-#define CHECK_KILL(x) ((x)->flags & USER_KILL)\r
-#define CHECK_GLINE(x) ((x)->flags & USER_GLINE)\r
-#define CHECK_WARNED(x) ((x)->flags & USER_WARNED)\r
-#define CHECK_KILLED(x) ((x)->flags & USER_KILLED)\r
-#define CHECK_ADV_WARNED(x) ((x)->flags & USER_ADV_WARNED)\r
-\r
-#define SPAM_WARNLEVEL 1\r
-\r
-#define FLOOD_TIMEQ_FREQ 5\r
-#define FLOOD_EXPIRE 5\r
-#define FLOOD_WARNLEVEL 1\r
-#define FLOOD_MAX_LINES 8\r
-\r
-#define JOINFLOOD_TIMEQ_FREQ 225\r
-#define JOINFLOOD_EXPIRE 450\r
-#define JOINFLOOD_MAX 3\r
-#define JOINFLOOD_B_DURATION 900\r
-\r
-#define ADV_TIMEQ_FREQ 300\r
-#define ADV_EXPIRE 900\r
-#define ADV_WARNLEVEL 2\r
-\r
-#define WARNLEVEL_TIMEQ_FREQ 1800\r
-#define MAX_WARNLEVEL 6\r
-\r
-#define KILL_TIMEQ_FREQ 450\r
-#define KILL_EXPIRE 1800\r
-#define KILL_WARNLEVEL 3\r
-\r
-struct spamNode\r
-{\r
- struct chanNode *channel;\r
- unsigned long crc32;\r
- unsigned int count;\r
- struct spamNode *prev;\r
- struct spamNode *next;\r
-};\r
-\r
-struct floodNode\r
-{\r
- struct chanNode *channel;\r
- struct userNode *owner;\r
- unsigned int count;\r
- time_t time;\r
- struct floodNode *prev;\r
- struct floodNode *next;\r
-};\r
-\r
-struct killNode\r
-{\r
- unsigned int warnlevel;\r
- time_t time;\r
-};\r
-\r
-struct userInfo\r
-{\r
- struct userNode *user;\r
- struct spamNode *spam;\r
- struct floodNode *flood;\r
- struct floodNode *joinflood;\r
- unsigned int flags : 30;\r
- unsigned int warnlevel;\r
- time_t lastadv;\r
-};\r
-\r
-struct badword {\r
- char *id;\r
- char *badword_mask;\r
- unsigned int triggered : 29;\r
- unsigned int action : 3;\r
-};\r
-\r
-/***********************************************/\r
-/* Other Stuff */\r
-/***********************************************/\r
-\r
-enum cs_unreg\r
-{\r
- manually,\r
- expire,\r
- lost_all_users\r
-};\r
-\r
-void init_spamserv(const char *nick);\r
-struct chanInfo *get_chanInfo(const char *channelname);\r
-void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text);\r
-void spamserv_cs_suspend(struct chanNode *channel, time_t expiry, int suspend, char *reason);\r
-int spamserv_cs_move_merge(struct userNode *user, struct chanNode *channel, struct chanNode *target, int move);\r
-void spamserv_cs_unregister(struct userNode *user, struct chanNode *channel, enum cs_unreg type, char *reason);\r
-static struct badword *add_badword(struct chanInfo *cInfo, const char *badword_mask, unsigned int triggered, unsigned int action, const char *id);\r
-\r
-#endif\r
+/* spamserv.h - anti spam service
+ * Copyright 2004 feigling
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version. Important limitations are
+ * listed in the COPYING file that accompanies this software.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, email srvx-maintainers@srvx.net.
+ *
+ * $Id: spamserv.h,v 1.3 2004/06/27 22:20:00 feigling Exp $
+ */
+
+#ifndef _spamserv_h
+#define _spamserv_h
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+/***********************************************/
+/* Channel */
+/***********************************************/
+
+enum channelinfo
+{
+ ci_SpamLimit = 0,
+ ci_AdvReaction,
+ ci_WarnReaction,
+ ci_Max
+};
+
+#define CHAN_INFO_SIZE (ci_Max + 1)
+#define CHAN_INFO_DEFAULT "bls"
+
+#define CHAN_SPAMSCAN 0x00000001
+#define CHAN_FLOODSCAN 0x00000002
+#define CHAN_JOINFLOOD 0x00000004
+#define CHAN_ADV_SCAN 0x00000008
+#define CHAN_SCAN_CHANOPS 0x00000010
+#define CHAN_SCAN_VOICED 0x00000020
+#define CHAN_SUSPENDED 0x00000040
+
+#define CHAN_FLAGS_DEFAULT (CHAN_SPAMSCAN | CHAN_FLOODSCAN | CHAN_JOINFLOOD)
+
+#define CHECK_SPAM(x) ((x)->flags & CHAN_SPAMSCAN)
+#define CHECK_FLOOD(x) ((x)->flags & CHAN_FLOODSCAN)
+#define CHECK_JOINFLOOD(x) ((x)->flags & CHAN_JOINFLOOD)
+#define CHECK_ADV(x) ((x)->flags & CHAN_ADV_SCAN)
+#define CHECK_CHANOPS(x) ((x)->flags & CHAN_SCAN_CHANOPS)
+#define CHECK_VOICED(x) ((x)->flags & CHAN_SCAN_VOICED)
+#define CHECK_SUSPENDED(x) ((x)->flags & CHAN_SUSPENDED)
+
+#define BADACTION_KICK 0
+#define BADACTION_BAN 1
+#define BADACTION_KILL 2
+#define BADACTION_GLINE 3
+
+struct chanInfo
+{
+ struct chanNode *channel;
+ struct string_list *exceptions;
+ dict_t badwords;
+ unsigned int flags : 30;
+ unsigned int exceptlevel;
+ char info[CHAN_INFO_SIZE];
+ unsigned long suspend_expiry;
+ unsigned int last_badword_id;
+};
+
+/***********************************************/
+/* User */
+/***********************************************/
+
+#define USER_KICK 0x00000001
+#define USER_KICKBAN 0x00000002
+#define USER_SHORT_TBAN 0x00000004
+#define USER_LONG_TBAN 0x00000008
+#define USER_KILL 0x00000010
+#define USER_GLINE 0x00000020
+#define USER_WARNED 0x00000040
+#define USER_KILLED 0x00000080
+#define USER_ADV_WARNED 0x00000100
+
+#define CHECK_KICK(x) ((x)->flags & USER_KICK)
+#define CHECK_KICKBAN(x) ((x)->flags & USER_KICKBAN)
+#define CHECK_SHORT_TBAN(x) ((x)->flags & USER_SHORT_TBAN)
+#define CHECK_LONG_TBAN(x) ((x)->flags & USER_LONG_TBAN)
+#define CHECK_KILL(x) ((x)->flags & USER_KILL)
+#define CHECK_GLINE(x) ((x)->flags & USER_GLINE)
+#define CHECK_WARNED(x) ((x)->flags & USER_WARNED)
+#define CHECK_KILLED(x) ((x)->flags & USER_KILLED)
+#define CHECK_ADV_WARNED(x) ((x)->flags & USER_ADV_WARNED)
+
+#define SPAM_WARNLEVEL 1
+
+#define FLOOD_TIMEQ_FREQ 5
+#define FLOOD_EXPIRE 5
+#define FLOOD_WARNLEVEL 1
+#define FLOOD_MAX_LINES 8
+
+#define JOINFLOOD_TIMEQ_FREQ 225
+#define JOINFLOOD_EXPIRE 450
+#define JOINFLOOD_MAX 3
+#define JOINFLOOD_B_DURATION 900
+
+#define ADV_TIMEQ_FREQ 300
+#define ADV_EXPIRE 900
+#define ADV_WARNLEVEL 2
+
+#define WARNLEVEL_TIMEQ_FREQ 1800
+#define MAX_WARNLEVEL 6
+
+#define KILL_TIMEQ_FREQ 450
+#define KILL_EXPIRE 1800
+#define KILL_WARNLEVEL 3
+
+struct spamNode
+{
+ struct chanNode *channel;
+ unsigned long crc32;
+ unsigned int count;
+ struct spamNode *prev;
+ struct spamNode *next;
+};
+
+struct floodNode
+{
+ struct chanNode *channel;
+ struct userNode *owner;
+ unsigned int count;
+ time_t time;
+ struct floodNode *prev;
+ struct floodNode *next;
+};
+
+struct killNode
+{
+ unsigned int warnlevel;
+ time_t time;
+};
+
+struct userInfo
+{
+ struct userNode *user;
+ struct spamNode *spam;
+ struct floodNode *flood;
+ struct floodNode *joinflood;
+ unsigned int flags : 30;
+ unsigned int warnlevel;
+ time_t lastadv;
+};
+
+struct badword {
+ char *id;
+ char *badword_mask;
+ unsigned int triggered : 29;
+ unsigned int action : 3;
+};
+
+/***********************************************/
+/* Other Stuff */
+/***********************************************/
+
+enum cs_unreg
+{
+ manually,
+ expire,
+ lost_all_users
+};
+
+void init_spamserv(const char *nick);
+struct chanInfo *get_chanInfo(const char *channelname);
+void spamserv_channel_message(struct chanNode *channel, struct userNode *user, char *text);
+void spamserv_cs_suspend(struct chanNode *channel, time_t expiry, int suspend, char *reason);
+int spamserv_cs_move_merge(struct userNode *user, struct chanNode *channel, struct chanNode *target, int move);
+void spamserv_cs_unregister(struct userNode *user, struct chanNode *channel, enum cs_unreg type, char *reason);
+static struct badword *add_badword(struct chanInfo *cInfo, const char *badword_mask, unsigned int triggered, unsigned int action, const char *id);
+
+#endif