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

Annotation of /botnetop.mod/botnetop.c

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


Revision 1.10 - (hide annotations) (download) (as text)
Wed Oct 20 17:30:51 2010 UTC (8 years, 5 months 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 sup 1.9 /*
2 sup 1.3 * botnetop.c -- part of botnetop.mod
3 sup 1.9 *
4 pseudo 1.10 * $Id: botnetop.c,v 1.9 2002/07/14 09:28:44 sup Exp $
5 sup 1.3 */
6     /*
7 sup 1.9 * Copyright (C) 2000, 2001, 2002 Teemu Hjelt <temex@iki.fi>
8 guppy 1.1 *
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 sup 1.9 #define MODULE_VERSION "1.1.0-gamma"
27 guppy 1.1 #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 sup 1.9 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 sup 1.7 static int strict_host = 0;
42 sup 1.4 static int bop_delay = 20;
43     static int bop_maxreq = 3;
44 guppy 1.1 static int bop_modeop = 0;
45     static int bop_linkop = 1;
46 sup 1.5 static int bop_icheck = 0;
47 sup 1.9 static int bop_hcheck = 1;
48 guppy 1.1 static int bop_osync = 0;
49     static int bop_addhost = 0;
50     static int bop_log = 2;
51 sup 1.9
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 guppy 1.1
64 sup 1.5 #include "botnetop.h"
65 sup 1.9 #include "botbinds.c"
66 guppy 1.1 #include "botcmds.c"
67 sup 1.9 #include "delay.c"
68     #include "flood.c"
69 guppy 1.1 #include "ircbinds.c"
70 sup 1.9 #include "misc.c"
71     #include "request.c"
72 guppy 1.1 #include "tclcmds.c"
73 sup 1.5 #include "who.c"
74    
75     static void botnetop_hook_secondly()
76     {
77     check_delay();
78     check_who();
79 sup 1.9 check_flood();
80 sup 1.5 }
81    
82     static void botnetop_hook_hourly()
83     {
84 sup 1.6 struct delay_t *d = NULL, *dnext = NULL;
85 sup 1.9 struct flood_t *f = NULL, *fnext = NULL;
86 sup 1.5
87 sup 1.9 for (d = delay_start; d != NULL; d = dnext) {
88 sup 1.6 dnext = d->next;
89 sup 1.9 if (!findchan_by_dname(d->chan))
90 sup 1.5 del_delay(d);
91     }
92 sup 1.9 for (f = flood_start; f != NULL; f = fnext) {
93     fnext = f->next;
94     if (!findchan_by_dname(f->chan))
95     del_flood(f);
96 sup 1.5 }
97     }
98 guppy 1.1
99     static int botnetop_expmem()
100     {
101 sup 1.9 return delay_expmem() + who_expmem() + flood_expmem() + request_expmem();
102 guppy 1.1 }
103    
104     static void botnetop_report(int idx, int details)
105     {
106 sup 1.9 int dtot = 0, wtot = 0, ftot = 0, rtot = 0;
107 sup 1.5 struct delay_t *d = NULL;
108     struct who_t *w = NULL;
109 sup 1.9 struct flood_t *f = NULL;
110     struct request_t *r = NULL;
111 sup 1.4
112 sup 1.9 for (d = delay_start; d != NULL; d = d->next)
113 sup 1.4 dtot++;
114 sup 1.9 for (w = who_start; w != NULL; w = w->next)
115 sup 1.5 wtot++;
116 sup 1.9 for (f = flood_start; f != NULL; f = f->next)
117     ftot++;
118     for (r = request_start; r != NULL; r = r->next)
119     rtot++;
120 sup 1.4 if (details) {
121 sup 1.9 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 sup 1.5 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 sup 1.9 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 sup 1.4 }
133 guppy 1.1 }
134    
135     static tcl_ints botnetop_tcl_ints[] =
136     {
137 sup 1.9 {"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 guppy 1.1 };
163    
164     static char *botnetop_close()
165     {
166 sup 1.5 del_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
167     del_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
168 sup 1.9 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 guppy 1.1 rem_builtins(H_join, botnetop_join);
174     rem_builtins(H_mode, botnetop_mode);
175 sup 1.5 rem_builtins(H_raw, botnetop_raw);
176 guppy 1.1 rem_builtins(H_link, botnetop_link);
177     rem_builtins(H_bot, botnetop_bot);
178 sup 1.3 rem_builtins(H_need, botnetop_need);
179 sup 1.4 delay_free_mem();
180 sup 1.5 who_free_mem();
181 sup 1.9 flood_free_mem();
182     request_free_mem();
183 guppy 1.1 module_undepend(MODULE_NAME);
184 sup 1.9
185 guppy 1.1 return NULL;
186     }
187    
188 sup 1.9 /* 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 guppy 1.1
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 sup 1.9
207     module_register(MODULE_NAME, botnetop_table, 1, 1);
208 pseudo 1.10 if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
209 sup 1.9 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 sup 1.7 }
215     }
216     if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0))) {
217     module_undepend(MODULE_NAME);
218 guppy 1.1 return "You need the irc module to use the botnetop module.";
219 sup 1.7 }
220     if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
221     module_undepend(MODULE_NAME);
222 guppy 1.1 return "You need the server module to use the botnetop module.";
223 sup 1.7 }
224     if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0))) {
225     module_undepend(MODULE_NAME);
226 guppy 1.1 return "You need the channels module to use the botnetop module.";
227 sup 1.7 }
228 sup 1.5 add_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
229     add_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
230 sup 1.9 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 guppy 1.1 add_builtins(H_join, botnetop_join);
236     add_builtins(H_mode, botnetop_mode);
237 sup 1.5 add_builtins(H_raw, botnetop_raw);
238 guppy 1.1 add_builtins(H_link, botnetop_link);
239     add_builtins(H_bot, botnetop_bot);
240 sup 1.3 add_builtins(H_need, botnetop_need);
241 sup 1.9
242 guppy 1.1 return NULL;
243     }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23