Remove cruft left behind by removed stats_p_hook.
[seven-1.x.git] / modules / m_info.c
blob734c3462c30ded67c8c9a15ae4ef3578469f0f86
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_info.c: Sends information about the server.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
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.
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
22 * USA
25 #include "stdinc.h"
26 #include "tools.h"
27 #include "m_info.h"
28 #include "channel.h"
29 #include "client.h"
30 #include "common.h"
31 #include "irc_string.h"
32 #include "ircd.h"
33 #include "hook.h"
34 #include "numeric.h"
35 #include "s_serv.h"
36 #include "s_user.h"
37 #include "send.h"
38 #include "s_conf.h"
39 #include "msg.h"
40 #include "parse.h"
41 #include "modules.h"
43 static void send_conf_options(struct Client *source_p);
44 static void send_birthdate_online_time(struct Client *source_p);
45 static void send_info_text(struct Client *source_p);
47 static int m_info(struct Client *, struct Client *, int, const char **);
48 static int mo_info(struct Client *, struct Client *, int, const char **);
50 struct Message info_msgtab = {
51 "INFO", 0, 0, 0, MFLG_SLOW,
52 {mg_unreg, {m_info, 0}, {mo_info, 0}, mg_ignore, mg_ignore, {mo_info, 0}}
55 int doing_info_hook;
57 mapi_clist_av1 info_clist[] = { &info_msgtab, NULL };
58 mapi_hlist_av1 info_hlist[] = {
59 { "doing_info", &doing_info_hook },
60 { NULL, NULL }
63 DECLARE_MODULE_AV1(info, NULL, NULL, info_clist, info_hlist, NULL, "$Revision: 151 $");
66 * jdc -- Structure for our configuration value table
68 struct InfoStruct
70 const char *name; /* Displayed variable name */
71 unsigned int output_type; /* See below #defines */
72 void *option; /* Pointer reference to the value */
73 const char *desc; /* ASCII description of the variable */
75 /* Types for output_type in InfoStruct */
76 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
77 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
78 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
79 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
80 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
81 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
83 /* *INDENT-OFF* */
84 static struct InfoStruct info_table[] = {
85 /* --[ START OF TABLE ]-------------------------------------------- */
87 "opers_see_all_users",
88 OUTPUT_BOOLEAN_YN,
89 &opers_see_all_users,
90 "Farconnect notices available"
93 "anti_nick_flood",
94 OUTPUT_BOOLEAN,
95 &ConfigFileEntry.anti_nick_flood,
96 "NICK flood protection"
99 "anti_spam_exit_message_time",
100 OUTPUT_DECIMAL,
101 &ConfigFileEntry.anti_spam_exit_message_time,
102 "Duration a client must be connected for to have an exit message"
105 "caller_id_wait",
106 OUTPUT_DECIMAL,
107 &ConfigFileEntry.caller_id_wait,
108 "Minimum delay between notifying UMODE +g users of messages"
111 "client_exit",
112 OUTPUT_BOOLEAN,
113 &ConfigFileEntry.client_exit,
114 "Prepend 'Client Exit:' to user QUIT messages"
117 "client_flood",
118 OUTPUT_DECIMAL,
119 &ConfigFileEntry.client_flood,
120 "Number of lines before a client Excess Flood's",
123 "connect_timeout",
124 OUTPUT_DECIMAL,
125 &ConfigFileEntry.connect_timeout,
126 "Connect timeout for connections to servers"
129 "default_floodcount",
130 OUTPUT_DECIMAL,
131 &ConfigFileEntry.default_floodcount,
132 "Startup value of FLOODCOUNT",
135 "default_adminstring",
136 OUTPUT_STRING,
137 &ConfigFileEntry.default_adminstring,
138 "Default adminstring at startup.",
141 "default_operstring",
142 OUTPUT_STRING,
143 &ConfigFileEntry.default_operstring,
144 "Default operstring at startup.",
147 "servicestring",
148 OUTPUT_STRING,
149 &ConfigFileEntry.servicestring,
150 "String shown in whois for opered services.",
153 "disable_auth",
154 OUTPUT_BOOLEAN_YN,
155 &ConfigFileEntry.disable_auth,
156 "Controls whether auth checking is disabled or not"
159 "disable_fake_channels",
160 OUTPUT_BOOLEAN_YN,
161 &ConfigFileEntry.disable_fake_channels,
162 "Controls whether bold etc are disabled for JOIN"
165 "dot_in_ip6_addr",
166 OUTPUT_BOOLEAN,
167 &ConfigFileEntry.dot_in_ip6_addr,
168 "Suffix a . to ip6 addresses",
171 "dots_in_ident",
172 OUTPUT_DECIMAL,
173 &ConfigFileEntry.dots_in_ident,
174 "Number of permissable dots in an ident"
177 "failed_oper_notice",
178 OUTPUT_BOOLEAN,
179 &ConfigFileEntry.failed_oper_notice,
180 "Inform opers if someone /oper's with the wrong password"
183 "fname_userlog",
184 OUTPUT_STRING,
185 &ConfigFileEntry.fname_userlog,
186 "User log file"
189 "fname_fuserlog",
190 OUTPUT_STRING,
191 &ConfigFileEntry.fname_fuserlog,
192 "Failed user log file"
196 "fname_operlog",
197 OUTPUT_STRING,
198 &ConfigFileEntry.fname_operlog,
199 "Operator log file"
202 "fname_foperlog",
203 OUTPUT_STRING,
204 &ConfigFileEntry.fname_foperlog,
205 "Failed operator log file"
208 "fname_serverlog",
209 OUTPUT_STRING,
210 &ConfigFileEntry.fname_serverlog,
211 "Server connect/disconnect log file"
214 "fname_klinelog",
215 OUTPUT_STRING,
216 &ConfigFileEntry.fname_klinelog,
217 "KLINE etc log file"
220 "fname_ioerrorlog",
221 OUTPUT_STRING,
222 &ConfigFileEntry.fname_ioerrorlog,
223 "IO error log file"
226 "global_snotices",
227 OUTPUT_BOOLEAN_YN,
228 &ConfigFileEntry.global_snotices,
229 "Send out certain server notices globally"
232 "hide_error_messages",
233 OUTPUT_BOOLEAN2,
234 &ConfigFileEntry.hide_error_messages,
235 "Hide ERROR messages coming from servers"
238 "hide_spoof_ips",
239 OUTPUT_BOOLEAN_YN,
240 &ConfigFileEntry.hide_spoof_ips,
241 "Hide IPs of spoofed users"
244 "hub",
245 OUTPUT_BOOLEAN_YN,
246 &ServerInfo.hub,
247 "Server is a hub"
250 "idletime",
251 OUTPUT_DECIMAL,
252 &ConfigFileEntry.idletime,
253 "Number of minutes before a client is considered idle"
256 "kline_delay",
257 OUTPUT_DECIMAL,
258 &ConfigFileEntry.kline_delay,
259 "Duration of time to delay kline checking"
262 "dline_with_reason",
263 OUTPUT_BOOLEAN_YN,
264 &ConfigFileEntry.dline_with_reason,
265 "Display D-line reason to client on disconnect"
268 "kline_with_reason",
269 OUTPUT_BOOLEAN_YN,
270 &ConfigFileEntry.kline_with_reason,
271 "Display K-line reason to client on disconnect"
274 "max_accept",
275 OUTPUT_DECIMAL,
276 &ConfigFileEntry.max_accept,
277 "Maximum nicknames on accept list",
280 "max_nick_changes",
281 OUTPUT_DECIMAL,
282 &ConfigFileEntry.max_nick_changes,
283 "NICK change threshhold setting"
286 "max_nick_time",
287 OUTPUT_DECIMAL,
288 &ConfigFileEntry.max_nick_time,
289 "NICK flood protection time interval"
292 "max_targets",
293 OUTPUT_DECIMAL,
294 &ConfigFileEntry.max_targets,
295 "The maximum number of PRIVMSG/NOTICE targets"
298 "min_nonwildcard",
299 OUTPUT_DECIMAL,
300 &ConfigFileEntry.min_nonwildcard,
301 "Minimum non-wildcard chars in K-lines",
304 "min_nonwildcard_simple",
305 OUTPUT_DECIMAL,
306 &ConfigFileEntry.min_nonwildcard_simple,
307 "Minimum non-wildcard chars in xlines/resvs",
310 "network_name",
311 OUTPUT_STRING,
312 &ServerInfo.network_name,
313 "Network name"
316 "network_desc",
317 OUTPUT_STRING,
318 &ServerInfo.network_desc,
319 "Network description"
322 "nick_delay",
323 OUTPUT_DECIMAL,
324 &ConfigFileEntry.nick_delay,
325 "Delay nicks are locked for on split",
328 "no_oper_flood",
329 OUTPUT_BOOLEAN,
330 &ConfigFileEntry.no_oper_flood,
331 "Disable flood control for operators",
334 "non_redundant_klines",
335 OUTPUT_BOOLEAN,
336 &ConfigFileEntry.non_redundant_klines,
337 "Check for and disallow redundant K-lines"
340 "pace_wait",
341 OUTPUT_DECIMAL,
342 &ConfigFileEntry.pace_wait,
343 "Minimum delay between uses of certain commands"
346 "pace_wait_simple",
347 OUTPUT_DECIMAL,
348 &ConfigFileEntry.pace_wait_simple,
349 "Minimum delay between less intensive commands"
352 "ping_cookie",
353 OUTPUT_BOOLEAN,
354 &ConfigFileEntry.ping_cookie,
355 "Require ping cookies to connect",
358 "reject_after_count",
359 OUTPUT_DECIMAL,
360 &ConfigFileEntry.reject_after_count,
361 "Client rejection threshold setting",
364 "reject_ban_time",
365 OUTPUT_DECIMAL,
366 &ConfigFileEntry.reject_ban_time,
367 "Client rejection time interval",
370 "reject_duration",
371 OUTPUT_DECIMAL,
372 &ConfigFileEntry.reject_duration,
373 "Client rejection cache duration",
376 "short_motd",
377 OUTPUT_BOOLEAN_YN,
378 &ConfigFileEntry.short_motd,
379 "Do not show MOTD; only tell clients they should read it"
382 "stats_e_disabled",
383 OUTPUT_BOOLEAN_YN,
384 &ConfigFileEntry.stats_e_disabled,
385 "STATS e output is disabled",
388 "stats_c_oper_only",
389 OUTPUT_BOOLEAN_YN,
390 &ConfigFileEntry.stats_c_oper_only,
391 "STATS C output is only shown to operators",
394 "stats_h_oper_only",
395 OUTPUT_BOOLEAN_YN,
396 &ConfigFileEntry.stats_h_oper_only,
397 "STATS H output is only shown to operators",
400 "stats_i_oper_only",
401 OUTPUT_BOOLEAN2,
402 &ConfigFileEntry.stats_i_oper_only,
403 "STATS I output is only shown to operators",
406 "stats_k_oper_only",
407 OUTPUT_BOOLEAN2,
408 &ConfigFileEntry.stats_k_oper_only,
409 "STATS K output is only shown to operators",
412 "stats_o_oper_only",
413 OUTPUT_BOOLEAN_YN,
414 &ConfigFileEntry.stats_o_oper_only,
415 "STATS O output is only shown to operators",
418 "stats_P_oper_only",
419 OUTPUT_BOOLEAN_YN,
420 &ConfigFileEntry.stats_P_oper_only,
421 "STATS P is only shown to operators",
424 "stats_y_oper_only",
425 OUTPUT_BOOLEAN_YN,
426 &ConfigFileEntry.stats_y_oper_only,
427 "STATS Y is only shown to operators",
430 "tkline_expire_notices",
431 OUTPUT_BOOLEAN,
432 &ConfigFileEntry.tkline_expire_notices,
433 "Notices given to opers when tklines expire"
436 "ts_max_delta",
437 OUTPUT_DECIMAL,
438 &ConfigFileEntry.ts_max_delta,
439 "Maximum permitted TS delta from another server"
442 "ts_warn_delta",
443 OUTPUT_DECIMAL,
444 &ConfigFileEntry.ts_warn_delta,
445 "Maximum permitted TS delta before displaying a warning"
448 "warn_no_nline",
449 OUTPUT_BOOLEAN,
450 &ConfigFileEntry.warn_no_nline,
451 "Display warning if connecting server lacks N-line"
454 "default_split_server_count",
455 OUTPUT_DECIMAL,
456 &ConfigChannel.default_split_server_count,
457 "Startup value of SPLITNUM",
460 "default_split_user_count",
461 OUTPUT_DECIMAL,
462 &ConfigChannel.default_split_user_count,
463 "Startup value of SPLITUSERS",
466 "knock_delay",
467 OUTPUT_DECIMAL,
468 &ConfigChannel.knock_delay,
469 "Delay between a users KNOCK attempts"
472 "knock_delay_channel",
473 OUTPUT_DECIMAL,
474 &ConfigChannel.knock_delay_channel,
475 "Delay between KNOCK attempts to a channel",
478 "invite_ops_only",
479 OUTPUT_BOOLEAN_YN,
480 &ConfigChannel.invite_ops_only,
481 "INVITE is restricted to channelops only"
484 "kick_on_split_riding",
485 OUTPUT_BOOLEAN_YN,
486 &ConfigChannel.kick_on_split_riding,
487 "Kick users riding splits to join +i or +k channels"
490 "max_bans",
491 OUTPUT_DECIMAL,
492 &ConfigChannel.max_bans,
493 "Total +b/e/I/q modes allowed in a channel",
496 "max_bans_large",
497 OUTPUT_DECIMAL,
498 &ConfigChannel.max_bans_large,
499 "Total +b/e/I/q modes allowed in a +L channel",
502 "max_chans_per_user",
503 OUTPUT_DECIMAL,
504 &ConfigChannel.max_chans_per_user,
505 "Maximum number of channels a user can join",
508 "no_create_on_split",
509 OUTPUT_BOOLEAN_YN,
510 &ConfigChannel.no_create_on_split,
511 "Disallow creation of channels when split",
514 "no_join_on_split",
515 OUTPUT_BOOLEAN_YN,
516 &ConfigChannel.no_join_on_split,
517 "Disallow joining channels when split",
520 "use_except",
521 OUTPUT_BOOLEAN_YN,
522 &ConfigChannel.use_except,
523 "Enable chanmode +e (ban exceptions)",
526 "use_invex",
527 OUTPUT_BOOLEAN_YN,
528 &ConfigChannel.use_invex,
529 "Enable chanmode +I (invite exceptions)",
532 "use_knock",
533 OUTPUT_BOOLEAN_YN,
534 &ConfigChannel.use_knock,
535 "Enable /KNOCK",
538 "disable_hidden",
539 OUTPUT_BOOLEAN_YN,
540 &ConfigServerHide.disable_hidden,
541 "Prevent servers from hiding themselves from a flattened /links",
544 "flatten_links",
545 OUTPUT_BOOLEAN_YN,
546 &ConfigServerHide.flatten_links,
547 "Flatten /links list",
550 "hidden",
551 OUTPUT_BOOLEAN_YN,
552 &ConfigServerHide.hidden,
553 "Hide this server from a flattened /links on remote servers",
556 "links_delay",
557 OUTPUT_DECIMAL,
558 &ConfigServerHide.links_delay,
559 "Links rehash delay"
561 /* --[ END OF TABLE ]---------------------------------------------- */
562 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
564 /* *INDENT-ON* */
567 ** m_info
568 ** parv[0] = sender prefix
569 ** parv[1] = servername
571 static int
572 m_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
574 static time_t last_used = 0L;
576 if((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
578 /* safe enough to give this on a local connect only */
579 sendto_one(source_p, form_str(RPL_LOAD2HI),
580 me.name, source_p->name, "INFO");
581 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
582 return 0;
584 else
585 last_used = CurrentTime;
587 if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME)
588 return 0;
590 send_info_text(source_p);
591 send_birthdate_online_time(source_p);
593 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
594 return 0;
598 ** mo_info
599 ** parv[0] = sender prefix
600 ** parv[1] = servername
602 static int
603 mo_info(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
605 if(hunt_server(client_p, source_p, ":%s INFO :%s", 1, parc, parv) == HUNTED_ISME)
607 send_info_text(source_p);
609 if(IsOperStaffer(source_p))
610 send_conf_options(source_p);
612 send_birthdate_online_time(source_p);
614 sendto_one_numeric(source_p, RPL_ENDOFINFO, form_str(RPL_ENDOFINFO));
617 return 0;
621 * send_info_text
623 * inputs - client pointer to send info text to
624 * output - none
625 * side effects - info text is sent to client
627 static void
628 send_info_text(struct Client *source_p)
630 const char **text = infotext;
632 while (*text)
634 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), *text++);
637 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), "");
641 * send_birthdate_online_time
643 * inputs - client pointer to send to
644 * output - none
645 * side effects - birthdate and online time are sent
647 static void
648 send_birthdate_online_time(struct Client *source_p)
650 sendto_one(source_p, ":%s %d %s :Birth Date: %s, compile # %s",
651 get_id(&me, source_p), RPL_INFO,
652 get_id(source_p, source_p), creation, generation);
654 sendto_one(source_p, ":%s %d %s :On-line since %s",
655 get_id(&me, source_p), RPL_INFO,
656 get_id(source_p, source_p), myctime(startup_time));
660 * send_conf_options
662 * inputs - client pointer to send to
663 * output - none
664 * side effects - send config options to client
666 static void
667 send_conf_options(struct Client *source_p)
669 Info *infoptr;
670 int i = 0;
673 * Now send them a list of all our configuration options
674 * (mostly from config.h)
676 for (infoptr = MyInformation; infoptr->name; infoptr++)
678 if(infoptr->intvalue)
680 sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
681 get_id(&me, source_p), RPL_INFO,
682 get_id(source_p, source_p),
683 infoptr->name, infoptr->intvalue,
684 infoptr->desc);
686 else
688 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
689 get_id(&me, source_p), RPL_INFO,
690 get_id(source_p, source_p),
691 infoptr->name, infoptr->strvalue,
692 infoptr->desc);
697 * Parse the info_table[] and do the magic.
699 for (i = 0; info_table[i].name; i++)
701 switch (info_table[i].output_type)
704 * For "char *" references
706 case OUTPUT_STRING:
708 char *option = *((char **) info_table[i].option);
710 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
711 get_id(&me, source_p), RPL_INFO,
712 get_id(source_p, source_p),
713 info_table[i].name,
714 option ? option : "NONE",
715 info_table[i].desc ? info_table[i].desc : "<none>");
717 break;
720 * For "char foo[]" references
722 case OUTPUT_STRING_PTR:
724 char *option = (char *) info_table[i].option;
726 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
727 get_id(&me, source_p), RPL_INFO,
728 get_id(source_p, source_p),
729 info_table[i].name,
730 EmptyString(option) ? "NONE" : option,
731 info_table[i].desc ? info_table[i].desc : "<none>");
733 break;
736 * Output info_table[i].option as a decimal value.
738 case OUTPUT_DECIMAL:
740 int option = *((int *) info_table[i].option);
742 sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
743 get_id(&me, source_p), RPL_INFO,
744 get_id(source_p, source_p),
745 info_table[i].name,
746 option,
747 info_table[i].desc ? info_table[i].desc : "<none>");
749 break;
753 * Output info_table[i].option as "ON" or "OFF"
755 case OUTPUT_BOOLEAN:
757 int option = *((int *) info_table[i].option);
759 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
760 get_id(&me, source_p), RPL_INFO,
761 get_id(source_p, source_p),
762 info_table[i].name,
763 option ? "ON" : "OFF",
764 info_table[i].desc ? info_table[i].desc : "<none>");
766 break;
769 * Output info_table[i].option as "YES" or "NO"
771 case OUTPUT_BOOLEAN_YN:
773 int option = *((int *) info_table[i].option);
775 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
776 get_id(&me, source_p), RPL_INFO,
777 get_id(source_p, source_p),
778 info_table[i].name,
779 option ? "YES" : "NO",
780 info_table[i].desc ? info_table[i].desc : "<none>");
782 break;
785 case OUTPUT_BOOLEAN2:
787 int option = *((int *) info_table[i].option);
789 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
790 me.name, RPL_INFO, source_p->name,
791 info_table[i].name,
792 option ? ((option == 1) ? "MASK" : "YES") : "NO",
793 info_table[i].desc ? info_table[i].desc : "<none>");
794 } /* switch (info_table[i].output_type) */
796 } /* forloop */
799 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
800 ** in order for it to show up properly to opers who issue INFO
803 sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), "");