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 $
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 'Quit:' to user QUIT messages"
125 "client_flood_max_lines",
127 &ConfigFileEntry
.client_flood_max_lines
,
128 "Number of lines before a client Excess Flood's",
131 "client_flood_burst_rate",
133 &ConfigFileEntry
.client_flood_burst_rate
,
134 "Maximum lines per second during flood grace period",
137 "client_flood_burst_max",
139 &ConfigFileEntry
.client_flood_burst_max
,
140 "Number of lines to process at once before delaying",
143 "client_flood_message_num",
145 &ConfigFileEntry
.client_flood_message_num
,
146 "Number of messages to allow per client_flood_message_time outside of burst",
149 "client_flood_message_time",
151 &ConfigFileEntry
.client_flood_message_time
,
152 "Time to allow per client_flood_message_num outside of burst",
157 &ConfigFileEntry
.connect_timeout
,
158 "Connect timeout for connections to servers"
161 "default_ident_timeout",
163 &ConfigFileEntry
.default_ident_timeout
,
164 "Amount of time the server waits for ident responses from clients",
167 "default_floodcount",
169 &ConfigFileEntry
.default_floodcount
,
170 "Startup value of FLOODCOUNT",
173 "default_adminstring",
175 &ConfigFileEntry
.default_adminstring
,
176 "Default adminstring at startup.",
179 "default_operstring",
181 &ConfigFileEntry
.default_operstring
,
182 "Default operstring at startup.",
187 &ConfigFileEntry
.servicestring
,
188 "String shown in whois for opered services.",
193 &ConfigFileEntry
.disable_auth
,
194 "Controls whether auth checking is disabled or not"
197 "disable_fake_channels",
199 &ConfigFileEntry
.disable_fake_channels
,
200 "Controls whether bold etc are disabled for JOIN"
205 &ConfigFileEntry
.dots_in_ident
,
206 "Number of permissable dots in an ident"
209 "failed_oper_notice",
211 &ConfigFileEntry
.failed_oper_notice
,
212 "Inform opers if someone /oper's with the wrong password"
217 &ConfigFileEntry
.fname_userlog
,
223 &ConfigFileEntry
.fname_fuserlog
,
224 "Failed user log file"
230 &ConfigFileEntry
.fname_operlog
,
236 &ConfigFileEntry
.fname_foperlog
,
237 "Failed operator log file"
242 &ConfigFileEntry
.fname_serverlog
,
243 "Server connect/disconnect log file"
248 &ConfigFileEntry
.fname_killlog
,
254 &ConfigFileEntry
.fname_klinelog
,
260 &ConfigFileEntry
.fname_operspylog
,
266 &ConfigFileEntry
.fname_ioerrorlog
,
272 &ConfigFileEntry
.global_snotices
,
273 "Send out certain server notices globally"
276 "hide_error_messages",
278 &ConfigFileEntry
.hide_error_messages
,
279 "Hide ERROR messages coming from servers"
284 &ConfigFileEntry
.hide_spoof_ips
,
285 "Hide IPs of spoofed users"
296 &ConfigFileEntry
.kline_delay
,
297 "Duration of time to delay kline checking"
302 &ConfigFileEntry
.kline_reason
,
303 "K-lined clients sign off with this reason"
308 &ConfigFileEntry
.dline_with_reason
,
309 "Display D-line reason to client on disconnect"
314 &ConfigFileEntry
.kline_with_reason
,
315 "Display K-line reason to client on disconnect"
320 &ConfigFileEntry
.max_accept
,
321 "Maximum nicknames on accept list",
326 &ConfigFileEntry
.max_nick_changes
,
327 "NICK change threshhold setting"
332 &ConfigFileEntry
.max_nick_time
,
333 "NICK flood protection time interval"
338 &ConfigFileEntry
.max_targets
,
339 "The maximum number of PRIVMSG/NOTICE targets"
344 &ConfigFileEntry
.min_nonwildcard
,
345 "Minimum non-wildcard chars in K lines",
348 "min_nonwildcard_simple",
350 &ConfigFileEntry
.min_nonwildcard_simple
,
351 "Minimum non-wildcard chars in xlines/resvs",
356 &ServerInfo
.network_name
,
362 &ServerInfo
.network_desc
,
363 "Network description"
368 &ConfigFileEntry
.nick_delay
,
369 "Delay nicks are locked for on split",
374 &ConfigFileEntry
.no_oper_flood
,
375 "Disable flood control for operators",
378 "non_redundant_klines",
380 &ConfigFileEntry
.non_redundant_klines
,
381 "Check for and disallow redundant K-lines"
384 "operspy_admin_only",
386 &ConfigFileEntry
.operspy_admin_only
,
387 "Send +Z operspy notices to admins only"
390 "operspy_dont_care_user_info",
392 &ConfigFileEntry
.operspy_dont_care_user_info
,
393 "Remove accountability and some '!' requirement from non-channel operspy"
398 &ConfigFileEntry
.pace_wait
,
399 "Minimum delay between uses of certain commands"
404 &ConfigFileEntry
.pace_wait_simple
,
405 "Minimum delay between less intensive commands"
410 &ConfigFileEntry
.ping_cookie
,
411 "Require ping cookies to connect",
414 "reject_after_count",
416 &ConfigFileEntry
.reject_after_count
,
417 "Client rejection threshold setting",
422 &ConfigFileEntry
.reject_ban_time
,
423 "Client rejection time interval",
428 &ConfigFileEntry
.reject_duration
,
429 "Client rejection cache duration",
434 &ConfigFileEntry
.short_motd
,
435 "Do not show MOTD; only tell clients they should read it"
440 &ConfigFileEntry
.stats_e_disabled
,
441 "STATS e output is disabled",
446 &ConfigFileEntry
.stats_c_oper_only
,
447 "STATS C output is only shown to operators",
452 &ConfigFileEntry
.stats_h_oper_only
,
453 "STATS H output is only shown to operators",
458 &ConfigFileEntry
.stats_i_oper_only
,
459 "STATS I output is only shown to operators",
464 &ConfigFileEntry
.stats_k_oper_only
,
465 "STATS K output is only shown to operators",
470 &ConfigFileEntry
.stats_o_oper_only
,
471 "STATS O output is only shown to operators",
476 &ConfigFileEntry
.stats_P_oper_only
,
477 "STATS P is only shown to operators",
482 &ConfigFileEntry
.stats_y_oper_only
,
483 "STATS Y is only shown to operators",
488 &ConfigFileEntry
.throttle_count
,
489 "Connection throttle threshold",
494 &ConfigFileEntry
.throttle_duration
,
495 "Connection throttle duration",
498 "tkline_expire_notices",
500 &ConfigFileEntry
.tkline_expire_notices
,
501 "Notices given to opers when tklines expire"
506 &ConfigFileEntry
.ts_max_delta
,
507 "Maximum permitted TS delta from another server"
512 &ConfigFileEntry
.ts_warn_delta
,
513 "Maximum permitted TS delta before displaying a warning"
518 &ConfigFileEntry
.warn_no_nline
,
519 "Display warning if connecting server lacks N-line"
522 "use_propagated_bans",
524 &ConfigFileEntry
.use_propagated_bans
,
525 "KLINE sets fully propagated bans"
528 "max_ratelimit_tokens",
530 &ConfigFileEntry
.max_ratelimit_tokens
,
531 "The maximum number of tokens that can be accumulated for executing rate-limited commands",
536 &ConfigFileEntry
.away_interval
,
537 "The minimum time between aways",
540 "default_split_server_count",
542 &ConfigChannel
.default_split_server_count
,
543 "Startup value of SPLITNUM",
546 "default_split_user_count",
548 &ConfigChannel
.default_split_user_count
,
549 "Startup value of SPLITUSERS",
554 &ConfigChannel
.knock_delay
,
555 "Delay between a users KNOCK attempts"
558 "knock_delay_channel",
560 &ConfigChannel
.knock_delay_channel
,
561 "Delay between KNOCK attempts to a channel",
564 "kick_on_split_riding",
566 &ConfigChannel
.kick_on_split_riding
,
567 "Kick users riding splits to join +i or +k channels"
570 "disable_local_channels",
572 &ConfigChannel
.disable_local_channels
,
573 "Disable local channels (&channels)"
578 &ConfigChannel
.max_bans
,
579 "Total +b/e/I/q modes allowed in a channel",
584 &ConfigChannel
.max_bans_large
,
585 "Total +b/e/I/q modes allowed in a +L channel",
588 "max_chans_per_user",
590 &ConfigChannel
.max_chans_per_user
,
591 "Maximum number of channels a user can join",
594 "no_create_on_split",
596 &ConfigChannel
.no_create_on_split
,
597 "Disallow creation of channels when split",
602 &ConfigChannel
.no_join_on_split
,
603 "Disallow joining channels when split",
606 "only_ascii_channels",
608 &ConfigChannel
.only_ascii_channels
,
609 "Controls whether non-ASCII is disabled for JOIN"
614 &ConfigChannel
.use_except
,
615 "Enable chanmode +e (ban exceptions)",
620 &ConfigChannel
.use_invex
,
621 "Enable chanmode +I (invite exceptions)",
626 &ConfigChannel
.use_forward
,
627 "Enable chanmode +f (channel forwarding)",
632 &ConfigChannel
.use_knock
,
638 &ConfigChannel
.resv_forcepart
,
639 "Force-part local users on channel RESV"
644 &ConfigServerHide
.disable_hidden
,
645 "Prevent servers from hiding themselves from a flattened /links",
650 &ConfigServerHide
.flatten_links
,
651 "Flatten /links list",
656 &ConfigServerHide
.hidden
,
657 "Hide this server from a flattened /links on remote servers",
662 &ConfigServerHide
.links_delay
,
665 /* --[ END OF TABLE ]---------------------------------------------- */
666 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
672 ** parv[1] = servername
675 m_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
677 static time_t last_used
= 0L;
679 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
681 /* safe enough to give this on a local connect only */
682 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
683 me
.name
, source_p
->name
, "INFO");
684 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
688 last_used
= rb_current_time();
690 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
695 send_info_text(source_p
);
696 send_birthdate_online_time(source_p
);
698 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
704 ** parv[1] = servername
707 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
709 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
712 send_info_text(source_p
);
716 send_conf_options(source_p
);
717 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
721 send_birthdate_online_time(source_p
);
723 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
732 * inputs - client pointer to send info text to
734 * side effects - info text is sent to client
737 send_info_text(struct Client
*source_p
)
739 const char **text
= infotext
;
743 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
746 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
750 * send_birthdate_online_time
752 * inputs - client pointer to send to
754 * side effects - birthdate and online time are sent
757 send_birthdate_online_time(struct Client
*source_p
)
759 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
760 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
761 get_id(&me
, source_p
), RPL_INFO
,
762 get_id(source_p
, source_p
), creation
, generation
);
764 sendto_one(source_p
, ":%s %d %s :On-line since %s",
765 get_id(&me
, source_p
), RPL_INFO
,
766 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
772 * inputs - client pointer to send to
774 * side effects - send config options to client
777 send_conf_options(struct Client
*source_p
)
783 * Now send them a list of all our configuration options
784 * (mostly from config.h)
786 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
788 if(infoptr
->intvalue
)
790 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
791 get_id(&me
, source_p
), RPL_INFO
,
792 get_id(source_p
, source_p
),
793 infoptr
->name
, infoptr
->intvalue
,
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
),
801 infoptr
->name
, infoptr
->strvalue
,
807 * Parse the info_table[] and do the magic.
809 for (i
= 0; info_table
[i
].name
; i
++)
811 switch (info_table
[i
].output_type
)
814 * For "char *" references
818 char *option
= *((char **) info_table
[i
].option
);
820 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
821 get_id(&me
, source_p
), RPL_INFO
,
822 get_id(source_p
, source_p
),
824 option
? option
: "NONE",
825 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
830 * For "char foo[]" references
832 case OUTPUT_STRING_PTR
:
834 char *option
= (char *) info_table
[i
].option
;
836 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
837 get_id(&me
, source_p
), RPL_INFO
,
838 get_id(source_p
, source_p
),
840 EmptyString(option
) ? "NONE" : option
,
841 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
846 * Output info_table[i].option as a decimal value.
850 int option
= *((int *) info_table
[i
].option
);
852 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
853 get_id(&me
, source_p
), RPL_INFO
,
854 get_id(source_p
, source_p
),
857 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
863 * Output info_table[i].option as "ON" or "OFF"
867 int option
= *((int *) info_table
[i
].option
);
869 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
870 get_id(&me
, source_p
), RPL_INFO
,
871 get_id(source_p
, source_p
),
873 option
? "ON" : "OFF",
874 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
879 * Output info_table[i].option as "YES" or "NO"
881 case OUTPUT_BOOLEAN_YN
:
883 int option
= *((int *) info_table
[i
].option
);
885 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
886 get_id(&me
, source_p
), RPL_INFO
,
887 get_id(source_p
, source_p
),
889 option
? "YES" : "NO",
890 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
895 case OUTPUT_BOOLEAN2
:
897 int option
= *((int *) info_table
[i
].option
);
899 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
900 me
.name
, RPL_INFO
, source_p
->name
,
902 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
903 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
904 } /* switch (info_table[i].output_type) */
909 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
910 ** in order for it to show up properly to opers who issue INFO
913 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
918 * input - pointer to client
920 * side effects - hook doing_info is called
923 info_spy(struct Client
*source_p
)
927 hd
.client
= source_p
;
928 hd
.arg1
= hd
.arg2
= NULL
;
930 call_hook(doing_info_hook
, &hd
);