/[cvs]/botnetop.mod/botnetop.c
ViewVC logotype

Contents of /botnetop.mod/botnetop.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.10 - (show annotations) (download) (as text)
Wed Oct 20 17:30:51 2010 UTC (8 years, 1 month ago) by pseudo
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +2 -2 lines
File MIME type: text/x-chdr
Updated dependencies to make the module run on eggdrop 1.8.x

1 /*
2 * botnetop.c -- part of botnetop.mod
3 *
4 * $Id: botnetop.c,v 1.9 2002/07/14 09:28:44 sup Exp $
5 */
6 /*
7 * Copyright (C) 2000, 2001, 2002 Teemu Hjelt <temex@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24 #define MODULE_NAME "botnetop"
25 #define MAKING_BOTNETOP
26 #define MODULE_VERSION "1.1.0-gamma"
27 #include "../module.h"
28 #include "../irc.mod/irc.h"
29 #include "../server.mod/server.h"
30 #include "../channels.mod/channels.h"
31
32 #undef global
33 static Function *global = NULL, *irc_funcs = NULL, *server_funcs = NULL, *channels_funcs = NULL;
34
35 static struct delay_t *delay_start = NULL;
36 static struct who_t *who_start = NULL;
37 static struct flood_t *flood_start = NULL;
38 static struct request_t *request_start = NULL;
39
40 /* Default variables */
41 static int strict_host = 0;
42 static int bop_delay = 20;
43 static int bop_maxreq = 3;
44 static int bop_modeop = 0;
45 static int bop_linkop = 1;
46 static int bop_icheck = 0;
47 static int bop_hcheck = 1;
48 static int bop_osync = 0;
49 static int bop_addhost = 0;
50 static int bop_log = 2;
51
52 /* Additional variables */
53 static int bop_modedeop = 0;
54 static int bop_onunban = 0;
55 static int bop_oninvite = 0;
56 static int bop_onlimit = 0;
57 static int bop_onkey = 0;
58 static int bop_lowbotslimit = 3;
59 static int bop_flood_amount = 10;
60 static int bop_flood_time = 20;
61 static int bop_ignore = 20;
62 static int bop_quickop = 0;
63
64 #include "botnetop.h"
65 #include "botbinds.c"
66 #include "botcmds.c"
67 #include "delay.c"
68 #include "flood.c"
69 #include "ircbinds.c"
70 #include "misc.c"
71 #include "request.c"
72 #include "tclcmds.c"
73 #include "who.c"
74
75 static void botnetop_hook_secondly()
76 {
77 check_delay();
78 check_who();
79 check_flood();
80 }
81
82 static void botnetop_hook_hourly()
83 {
84 struct delay_t *d = NULL, *dnext = NULL;
85 struct flood_t *f = NULL, *fnext = NULL;
86
87 for (d = delay_start; d != NULL; d = dnext) {
88 dnext = d->next;
89 if (!findchan_by_dname(d->chan))
90 del_delay(d);
91 }
92 for (f = flood_start; f != NULL; f = fnext) {
93 fnext = f->next;
94 if (!findchan_by_dname(f->chan))
95 del_flood(f);
96 }
97 }
98
99 static int botnetop_expmem()
100 {
101 return delay_expmem() + who_expmem() + flood_expmem() + request_expmem();
102 }
103
104 static void botnetop_report(int idx, int details)
105 {
106 int dtot = 0, wtot = 0, ftot = 0, rtot = 0;
107 struct delay_t *d = NULL;
108 struct who_t *w = NULL;
109 struct flood_t *f = NULL;
110 struct request_t *r = NULL;
111
112 for (d = delay_start; d != NULL; d = d->next)
113 dtot++;
114 for (w = who_start; w != NULL; w = w->next)
115 wtot++;
116 for (f = flood_start; f != NULL; f = f->next)
117 ftot++;
118 for (r = request_start; r != NULL; r = r->next)
119 rtot++;
120 if (details) {
121 dprintf(idx, " Module version: %s\n", MODULE_VERSION);
122 #ifdef ENABLE_TCL_COMMANDS
123 dprintf(idx, " Tcl commands are enabled.\n");
124 #else
125 dprintf(idx, " Tcl commands are disabled.\n");
126 #endif
127 dprintf(idx, " %d delay record%s using %d bytes\n", dtot, dtot == 1 ? "" : "s", delay_expmem());
128 dprintf(idx, " %d who record%s using %d bytes\n", wtot, wtot == 1 ? "" : "s", who_expmem());
129 dprintf(idx, " %d flood record%s using %d bytes\n", ftot, ftot == 1 ? "" : "s", flood_expmem());
130 dprintf(idx, " %d request record%s using %d bytes\n", rtot, rtot == 1 ? "" : "s", request_expmem());
131 dprintf(idx, " botnetop.mod is using altogether %d bytes\n", botnetop_expmem());
132 }
133 }
134
135 static tcl_ints botnetop_tcl_ints[] =
136 {
137 {"strict-host", &strict_host, 0},
138 {"bop_delay", &bop_delay, 0},
139 {"bop_maxreq", &bop_maxreq, 0},
140 {"bop_modeop", &bop_modeop, 0},
141 {"bop_linkop", &bop_linkop, 0},
142 {"bop_icheck", &bop_icheck, 0},
143 {"bop_hcheck", &bop_hcheck, 0},
144 {"bop_osync", &bop_osync, 0},
145 {"bop_addhost", &bop_addhost, 0},
146 {"bop_log", &bop_log, 0},
147 {"bop_modedeop", &bop_modedeop, 0},
148 {"bop_onunban", &bop_onunban, 0},
149 {"bop_oninvite", &bop_oninvite, 0},
150 {"bop_onlimit", &bop_onlimit, 0},
151 {"bop_onkey", &bop_onkey, 0},
152 {"bop_lowbotslimit", &bop_lowbotslimit, 0},
153 {"bop_ignore", &bop_ignore, 0},
154 {"bop_quickop", &bop_quickop, 0},
155 {0, 0, 0}
156 };
157
158 static tcl_coups botnetop_tcl_coups[] =
159 {
160 {"bop_flood", &bop_flood_amount, &bop_flood_time},
161 {0, 0, 0}
162 };
163
164 static char *botnetop_close()
165 {
166 del_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
167 del_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
168 rem_tcl_ints(botnetop_tcl_ints);
169 rem_tcl_coups(botnetop_tcl_coups);
170 #ifdef ENABLE_TCL_COMMANDS
171 rem_tcl_commands(botnetop_tcl_cmds);
172 #endif
173 rem_builtins(H_join, botnetop_join);
174 rem_builtins(H_mode, botnetop_mode);
175 rem_builtins(H_raw, botnetop_raw);
176 rem_builtins(H_link, botnetop_link);
177 rem_builtins(H_bot, botnetop_bot);
178 rem_builtins(H_need, botnetop_need);
179 delay_free_mem();
180 who_free_mem();
181 flood_free_mem();
182 request_free_mem();
183 module_undepend(MODULE_NAME);
184
185 return NULL;
186 }
187
188 /* Ugly hack to get it work on Cygwin dynamically. */
189 #if defined (__CYGWIN__) && !defined(STATIC)
190 __declspec(dllexport) char * __cdecl botnetop_start();
191 #else
192 char *botnetop_start();
193 #endif
194
195 static Function botnetop_table[] =
196 {
197 (Function) botnetop_start,
198 (Function) botnetop_close,
199 (Function) botnetop_expmem,
200 (Function) botnetop_report,
201 };
202
203 char *botnetop_start(Function * global_funcs)
204 {
205 global = global_funcs;
206
207 module_register(MODULE_NAME, botnetop_table, 1, 1);
208 if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
209 if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
210 if (!module_depend(MODULE_NAME, "eggdrop", 105, 4)) {
211 module_undepend(MODULE_NAME);
212 return "This module requires eggdrop1.5.4 or later";
213 }
214 }
215 }
216 if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0))) {
217 module_undepend(MODULE_NAME);
218 return "You need the irc module to use the botnetop module.";
219 }
220 if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
221 module_undepend(MODULE_NAME);
222 return "You need the server module to use the botnetop module.";
223 }
224 if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0))) {
225 module_undepend(MODULE_NAME);
226 return "You need the channels module to use the botnetop module.";
227 }
228 add_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
229 add_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
230 add_tcl_ints(botnetop_tcl_ints);
231 add_tcl_coups(botnetop_tcl_coups);
232 #ifdef ENABLE_TCL_COMMANDS
233 add_tcl_commands(botnetop_tcl_cmds);
234 #endif
235 add_builtins(H_join, botnetop_join);
236 add_builtins(H_mode, botnetop_mode);
237 add_builtins(H_raw, botnetop_raw);
238 add_builtins(H_link, botnetop_link);
239 add_builtins(H_bot, botnetop_bot);
240 add_builtins(H_need, botnetop_need);
241
242 return NULL;
243 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23