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
24 * $Id: m_info.c 3396 2007-04-05 00:38:52Z jilles $
32 #include "irc_string.h"
44 static void send_conf_options(struct Client
*source_p
);
45 static void send_birthdate_online_time(struct Client
*source_p
);
46 static void send_info_text(struct Client
*source_p
);
47 static void info_spy(struct Client
*);
49 static int m_info(struct Client
*, struct Client
*, int, const char **);
50 static int mo_info(struct Client
*, struct Client
*, int, const char **);
52 struct Message info_msgtab
= {
53 "INFO", 0, 0, 0, MFLG_SLOW
,
54 {mg_unreg
, {m_info
, 0}, {mo_info
, 0}, mg_ignore
, mg_ignore
, {mo_info
, 0}}
59 mapi_clist_av1 info_clist
[] = { &info_msgtab
, NULL
};
60 mapi_hlist_av1 info_hlist
[] = {
61 { "doing_info", &doing_info_hook
},
65 DECLARE_MODULE_AV1(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, "$Revision: 3396 $");
68 * jdc -- Structure for our configuration value table
72 const char *name
; /* Displayed variable name */
73 unsigned int output_type
; /* See below #defines */
74 void *option
; /* Pointer reference to the value */
75 const char *desc
; /* ASCII description of the variable */
77 /* Types for output_type in InfoStruct */
78 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
79 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
80 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
81 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
82 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
83 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
86 static struct InfoStruct info_table
[] = {
87 /* --[ START OF TABLE ]-------------------------------------------- */
89 "opers_see_all_users",
92 "Farconnect notices available or operspy accountability limited"
98 "Max number connections"
103 &ConfigFileEntry
.anti_nick_flood
,
104 "NICK flood protection"
107 "anti_spam_exit_message_time",
109 &ConfigFileEntry
.anti_spam_exit_message_time
,
110 "Duration a client must be connected for to have an exit message"
115 &ConfigFileEntry
.caller_id_wait
,
116 "Minimum delay between notifying UMODE +g users of messages"
121 &ConfigFileEntry
.client_exit
,
122 "Prepend 'Client Exit:' to user QUIT messages"
127 &ConfigFileEntry
.client_flood
,
128 "Number of lines before a client Excess Flood's",
133 &ConfigFileEntry
.connect_timeout
,
134 "Connect timeout for connections to servers"
137 "default_floodcount",
139 &ConfigFileEntry
.default_floodcount
,
140 "Startup value of FLOODCOUNT",
143 "default_adminstring",
145 &ConfigFileEntry
.default_adminstring
,
146 "Default adminstring at startup.",
149 "default_operstring",
151 &ConfigFileEntry
.default_operstring
,
152 "Default operstring at startup.",
157 &ConfigFileEntry
.servicestring
,
158 "String shown in whois for opered services.",
163 &ConfigFileEntry
.disable_auth
,
164 "Controls whether auth checking is disabled or not"
167 "disable_fake_channels",
169 &ConfigFileEntry
.disable_fake_channels
,
170 "Controls whether bold etc are disabled for JOIN"
175 &ConfigFileEntry
.dots_in_ident
,
176 "Number of permissable dots in an ident"
179 "failed_oper_notice",
181 &ConfigFileEntry
.failed_oper_notice
,
182 "Inform opers if someone /oper's with the wrong password"
187 &ConfigFileEntry
.fname_userlog
,
193 &ConfigFileEntry
.fname_fuserlog
,
194 "Failed user log file"
200 &ConfigFileEntry
.fname_operlog
,
206 &ConfigFileEntry
.fname_foperlog
,
207 "Failed operator log file"
212 &ConfigFileEntry
.fname_serverlog
,
213 "Server connect/disconnect log file"
218 &ConfigFileEntry
.fname_klinelog
,
224 &ConfigFileEntry
.fname_operspylog
,
230 &ConfigFileEntry
.fname_ioerrorlog
,
236 &ConfigFileEntry
.global_snotices
,
237 "Send out certain server notices globally"
240 "hide_error_messages",
242 &ConfigFileEntry
.hide_error_messages
,
243 "Hide ERROR messages coming from servers"
248 &ConfigFileEntry
.hide_spoof_ips
,
249 "Hide IPs of spoofed users"
260 &ConfigFileEntry
.kline_delay
,
261 "Duration of time to delay kline checking"
266 &ConfigFileEntry
.kline_reason
,
267 "K-lined clients sign off with this reason"
272 &ConfigFileEntry
.dline_with_reason
,
273 "Display D-line reason to client on disconnect"
278 &ConfigFileEntry
.kline_with_reason
,
279 "Display K-line reason to client on disconnect"
284 &ConfigFileEntry
.max_accept
,
285 "Maximum nicknames on accept list",
290 &ConfigFileEntry
.max_nick_changes
,
291 "NICK change threshhold setting"
296 &ConfigFileEntry
.max_nick_time
,
297 "NICK flood protection time interval"
302 &ConfigFileEntry
.max_targets
,
303 "The maximum number of PRIVMSG/NOTICE targets"
308 &ConfigFileEntry
.min_nonwildcard
,
309 "Minimum non-wildcard chars in K lines",
312 "min_nonwildcard_simple",
314 &ConfigFileEntry
.min_nonwildcard_simple
,
315 "Minimum non-wildcard chars in xlines/resvs",
320 &ServerInfo
.network_name
,
326 &ServerInfo
.network_desc
,
327 "Network description"
332 &ConfigFileEntry
.nick_delay
,
333 "Delay nicks are locked for on split",
338 &ConfigFileEntry
.no_oper_flood
,
339 "Disable flood control for operators",
342 "non_redundant_klines",
344 &ConfigFileEntry
.non_redundant_klines
,
345 "Check for and disallow redundant K-lines"
348 "operspy_admin_only",
350 &ConfigFileEntry
.operspy_admin_only
,
351 "Send +Z operspy notices to admins only"
354 "operspy_dont_care_user_info",
356 &ConfigFileEntry
.operspy_dont_care_user_info
,
357 "Remove accountability and some '!' requirement from non-channel operspy"
362 &ConfigFileEntry
.pace_wait
,
363 "Minimum delay between uses of certain commands"
368 &ConfigFileEntry
.pace_wait_simple
,
369 "Minimum delay between less intensive commands"
374 &ConfigFileEntry
.ping_cookie
,
375 "Require ping cookies to connect",
378 "reject_after_count",
380 &ConfigFileEntry
.reject_after_count
,
381 "Client rejection threshold setting",
386 &ConfigFileEntry
.reject_ban_time
,
387 "Client rejection time interval",
392 &ConfigFileEntry
.reject_duration
,
393 "Client rejection cache duration",
398 &ConfigFileEntry
.short_motd
,
399 "Do not show MOTD; only tell clients they should read it"
404 &ConfigFileEntry
.stats_e_disabled
,
405 "STATS e output is disabled",
410 &ConfigFileEntry
.stats_c_oper_only
,
411 "STATS C output is only shown to operators",
416 &ConfigFileEntry
.stats_h_oper_only
,
417 "STATS H output is only shown to operators",
422 &ConfigFileEntry
.stats_i_oper_only
,
423 "STATS I output is only shown to operators",
428 &ConfigFileEntry
.stats_k_oper_only
,
429 "STATS K output is only shown to operators",
434 &ConfigFileEntry
.stats_o_oper_only
,
435 "STATS O output is only shown to operators",
440 &ConfigFileEntry
.stats_P_oper_only
,
441 "STATS P is only shown to operators",
446 &ConfigFileEntry
.stats_y_oper_only
,
447 "STATS Y is only shown to operators",
450 "tkline_expire_notices",
452 &ConfigFileEntry
.tkline_expire_notices
,
453 "Notices given to opers when tklines expire"
458 &ConfigFileEntry
.ts_max_delta
,
459 "Maximum permitted TS delta from another server"
464 &ConfigFileEntry
.ts_warn_delta
,
465 "Maximum permitted TS delta before displaying a warning"
470 &ConfigFileEntry
.warn_no_nline
,
471 "Display warning if connecting server lacks N-line"
474 "default_split_server_count",
476 &ConfigChannel
.default_split_server_count
,
477 "Startup value of SPLITNUM",
480 "default_split_user_count",
482 &ConfigChannel
.default_split_user_count
,
483 "Startup value of SPLITUSERS",
488 &ConfigChannel
.knock_delay
,
489 "Delay between a users KNOCK attempts"
492 "knock_delay_channel",
494 &ConfigChannel
.knock_delay_channel
,
495 "Delay between KNOCK attempts to a channel",
498 "kick_on_split_riding",
500 &ConfigChannel
.kick_on_split_riding
,
501 "Kick users riding splits to join +i or +k channels"
506 &ConfigChannel
.max_bans
,
507 "Total +b/e/I/q modes allowed in a channel",
512 &ConfigChannel
.max_bans_large
,
513 "Total +b/e/I/q modes allowed in a +L channel",
516 "max_chans_per_user",
518 &ConfigChannel
.max_chans_per_user
,
519 "Maximum number of channels a user can join",
522 "no_create_on_split",
524 &ConfigChannel
.no_create_on_split
,
525 "Disallow creation of channels when split",
530 &ConfigChannel
.no_join_on_split
,
531 "Disallow joining channels when split",
536 &ConfigChannel
.use_except
,
537 "Enable chanmode +e (ban exceptions)",
542 &ConfigChannel
.use_invex
,
543 "Enable chanmode +I (invite exceptions)",
548 &ConfigChannel
.use_forward
,
549 "Enable chanmode +f (channel forwarding)",
554 &ConfigChannel
.use_knock
,
560 &ConfigServerHide
.disable_hidden
,
561 "Prevent servers from hiding themselves from a flattened /links",
566 &ConfigServerHide
.flatten_links
,
567 "Flatten /links list",
572 &ConfigServerHide
.hidden
,
573 "Hide this server from a flattened /links on remote servers",
578 &ConfigServerHide
.links_delay
,
581 /* --[ END OF TABLE ]---------------------------------------------- */
582 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
588 ** parv[0] = sender prefix
589 ** parv[1] = servername
592 m_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
594 static time_t last_used
= 0L;
596 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
598 /* safe enough to give this on a local connect only */
599 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
600 me
.name
, source_p
->name
, "INFO");
601 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
605 last_used
= rb_current_time();
607 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
612 send_info_text(source_p
);
613 send_birthdate_online_time(source_p
);
615 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
621 ** parv[0] = sender prefix
622 ** parv[1] = servername
625 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
627 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
630 send_info_text(source_p
);
633 send_conf_options(source_p
);
635 send_birthdate_online_time(source_p
);
637 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
646 * inputs - client pointer to send info text to
648 * side effects - info text is sent to client
651 send_info_text(struct Client
*source_p
)
653 const char **text
= infotext
;
657 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
660 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
664 * send_birthdate_online_time
666 * inputs - client pointer to send to
668 * side effects - birthdate and online time are sent
671 send_birthdate_online_time(struct Client
*source_p
)
673 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
674 get_id(&me
, source_p
), RPL_INFO
,
675 get_id(source_p
, source_p
), creation
, generation
);
677 sendto_one(source_p
, ":%s %d %s :On-line since %s",
678 get_id(&me
, source_p
), RPL_INFO
,
679 get_id(source_p
, source_p
), myctime(startup_time
));
685 * inputs - client pointer to send to
687 * side effects - send config options to client
690 send_conf_options(struct Client
*source_p
)
696 * Now send them a list of all our configuration options
697 * (mostly from config.h)
699 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
701 if(infoptr
->intvalue
)
703 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
704 get_id(&me
, source_p
), RPL_INFO
,
705 get_id(source_p
, source_p
),
706 infoptr
->name
, infoptr
->intvalue
,
711 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
712 get_id(&me
, source_p
), RPL_INFO
,
713 get_id(source_p
, source_p
),
714 infoptr
->name
, infoptr
->strvalue
,
720 * Parse the info_table[] and do the magic.
722 for (i
= 0; info_table
[i
].name
; i
++)
724 switch (info_table
[i
].output_type
)
727 * For "char *" references
731 char *option
= *((char **) info_table
[i
].option
);
733 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
734 get_id(&me
, source_p
), RPL_INFO
,
735 get_id(source_p
, source_p
),
737 option
? option
: "NONE",
738 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
743 * For "char foo[]" references
745 case OUTPUT_STRING_PTR
:
747 char *option
= (char *) info_table
[i
].option
;
749 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
750 get_id(&me
, source_p
), RPL_INFO
,
751 get_id(source_p
, source_p
),
753 EmptyString(option
) ? "NONE" : option
,
754 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
759 * Output info_table[i].option as a decimal value.
763 int option
= *((int *) info_table
[i
].option
);
765 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
766 get_id(&me
, source_p
), RPL_INFO
,
767 get_id(source_p
, source_p
),
770 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
776 * Output info_table[i].option as "ON" or "OFF"
780 int option
= *((int *) info_table
[i
].option
);
782 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
783 get_id(&me
, source_p
), RPL_INFO
,
784 get_id(source_p
, source_p
),
786 option
? "ON" : "OFF",
787 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
792 * Output info_table[i].option as "YES" or "NO"
794 case OUTPUT_BOOLEAN_YN
:
796 int option
= *((int *) info_table
[i
].option
);
798 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
799 get_id(&me
, source_p
), RPL_INFO
,
800 get_id(source_p
, source_p
),
802 option
? "YES" : "NO",
803 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
808 case OUTPUT_BOOLEAN2
:
810 int option
= *((int *) info_table
[i
].option
);
812 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
813 me
.name
, RPL_INFO
, source_p
->name
,
815 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
816 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
817 } /* switch (info_table[i].output_type) */
822 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
823 ** in order for it to show up properly to opers who issue INFO
826 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
831 * input - pointer to client
833 * side effects - hook doing_info is called
836 info_spy(struct Client
*source_p
)
840 hd
.client
= source_p
;
841 hd
.arg1
= hd
.arg2
= NULL
;
843 call_hook(doing_info_hook
, &hd
);