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
41 static const char info_desc
[] =
42 "Provides the INFO command for retrieving server copyright, credits, and other info";
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 void m_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
50 static void mo_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
52 struct Message info_msgtab
= {
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_AV2(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, NULL
, NULL
, info_desc
);
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",
155 "post_registration_delay",
157 &ConfigFileEntry
.post_registration_delay
,
158 "Time to wait before processing commands from a new client",
163 &ConfigFileEntry
.connect_timeout
,
164 "Connect timeout for connections to servers"
167 "default_ident_timeout",
169 &ConfigFileEntry
.default_ident_timeout
,
170 "Amount of time the server waits for ident responses from clients",
173 "default_floodcount",
175 &ConfigFileEntry
.default_floodcount
,
176 "Startup value of FLOODCOUNT",
179 "default_adminstring",
181 &ConfigFileEntry
.default_adminstring
,
182 "Default adminstring at startup.",
185 "default_operstring",
187 &ConfigFileEntry
.default_operstring
,
188 "Default operstring at startup.",
193 &ConfigFileEntry
.servicestring
,
194 "String shown in whois for opered services.",
199 &ConfigFileEntry
.disable_auth
,
200 "Controls whether auth checking is disabled or not"
203 "disable_fake_channels",
205 &ConfigFileEntry
.disable_fake_channels
,
206 "Controls whether bold etc are disabled for JOIN"
211 &ConfigFileEntry
.dots_in_ident
,
212 "Number of permissable dots in an ident"
215 "failed_oper_notice",
217 &ConfigFileEntry
.failed_oper_notice
,
218 "Inform opers if someone /oper's with the wrong password"
223 &ConfigFileEntry
.fname_userlog
,
229 &ConfigFileEntry
.fname_fuserlog
,
230 "Failed user log file"
236 &ConfigFileEntry
.fname_operlog
,
242 &ConfigFileEntry
.fname_foperlog
,
243 "Failed operator log file"
248 &ConfigFileEntry
.fname_serverlog
,
249 "Server connect/disconnect log file"
254 &ConfigFileEntry
.fname_killlog
,
260 &ConfigFileEntry
.fname_klinelog
,
266 &ConfigFileEntry
.fname_operspylog
,
272 &ConfigFileEntry
.fname_ioerrorlog
,
278 &ConfigFileEntry
.global_snotices
,
279 "Send out certain server notices globally"
282 "hide_error_messages",
284 &ConfigFileEntry
.hide_error_messages
,
285 "Hide ERROR messages coming from servers"
290 &ConfigFileEntry
.hide_spoof_ips
,
291 "Hide IPs of spoofed users"
296 &ConfigFileEntry
.kline_reason
,
297 "K-lined clients sign off with this reason"
302 &ConfigFileEntry
.dline_with_reason
,
303 "Display D-line reason to client on disconnect"
308 &ConfigFileEntry
.kline_with_reason
,
309 "Display K-line reason to client on disconnect"
314 &ConfigFileEntry
.max_accept
,
315 "Maximum nicknames on accept list",
320 &ConfigFileEntry
.max_nick_changes
,
321 "NICK change threshhold setting"
326 &ConfigFileEntry
.max_nick_time
,
327 "NICK flood protection time interval"
332 &ConfigFileEntry
.max_targets
,
333 "The maximum number of PRIVMSG/NOTICE targets"
338 &ConfigFileEntry
.min_nonwildcard
,
339 "Minimum non-wildcard chars in K lines",
342 "min_nonwildcard_simple",
344 &ConfigFileEntry
.min_nonwildcard_simple
,
345 "Minimum non-wildcard chars in xlines/resvs",
350 &ServerInfo
.network_name
,
356 &ConfigFileEntry
.nick_delay
,
357 "Delay nicks are locked for on split",
362 &ConfigFileEntry
.no_oper_flood
,
363 "Disable flood control for operators",
366 "non_redundant_klines",
368 &ConfigFileEntry
.non_redundant_klines
,
369 "Check for and disallow redundant K-lines"
372 "operspy_admin_only",
374 &ConfigFileEntry
.operspy_admin_only
,
375 "Send +Z operspy notices to admins only"
378 "operspy_dont_care_user_info",
380 &ConfigFileEntry
.operspy_dont_care_user_info
,
381 "Remove accountability and some '!' requirement from non-channel operspy"
386 &ConfigFileEntry
.pace_wait
,
387 "Minimum delay between uses of certain commands"
392 &ConfigFileEntry
.pace_wait_simple
,
393 "Minimum delay between less intensive commands"
398 &ConfigFileEntry
.ping_cookie
,
399 "Require ping cookies to connect",
402 "reject_after_count",
404 &ConfigFileEntry
.reject_after_count
,
405 "Client rejection threshold setting",
410 &ConfigFileEntry
.reject_ban_time
,
411 "Client rejection time interval",
416 &ConfigFileEntry
.reject_duration
,
417 "Client rejection cache duration",
422 &ConfigFileEntry
.short_motd
,
423 "Do not show MOTD; only tell clients they should read it"
428 &ConfigFileEntry
.stats_e_disabled
,
429 "STATS e output is disabled",
434 &ConfigFileEntry
.stats_c_oper_only
,
435 "STATS C output is only shown to operators",
440 &ConfigFileEntry
.stats_h_oper_only
,
441 "STATS H output is only shown to operators",
446 &ConfigFileEntry
.stats_i_oper_only
,
447 "STATS I output is only shown to operators",
452 &ConfigFileEntry
.stats_k_oper_only
,
453 "STATS K output is only shown to operators",
458 &ConfigFileEntry
.stats_o_oper_only
,
459 "STATS O output is only shown to operators",
464 &ConfigFileEntry
.stats_P_oper_only
,
465 "STATS P is only shown to operators",
470 &ConfigFileEntry
.stats_y_oper_only
,
471 "STATS Y is only shown to operators",
476 &ConfigFileEntry
.throttle_count
,
477 "Connection throttle threshold",
482 &ConfigFileEntry
.throttle_duration
,
483 "Connection throttle duration",
486 "tkline_expire_notices",
488 &ConfigFileEntry
.tkline_expire_notices
,
489 "Notices given to opers when tklines expire"
494 &ConfigFileEntry
.ts_max_delta
,
495 "Maximum permitted TS delta from another server"
500 &ConfigFileEntry
.ts_warn_delta
,
501 "Maximum permitted TS delta before displaying a warning"
506 &ConfigFileEntry
.warn_no_nline
,
507 "Display warning if connecting server lacks connect block"
510 "use_propagated_bans",
512 &ConfigFileEntry
.use_propagated_bans
,
513 "KLINE sets fully propagated bans"
516 "max_ratelimit_tokens",
518 &ConfigFileEntry
.max_ratelimit_tokens
,
519 "The maximum number of tokens that can be accumulated for executing rate-limited commands",
524 &ConfigFileEntry
.away_interval
,
525 "The minimum time between aways",
528 "tls_ciphers_oper_only",
530 &ConfigFileEntry
.tls_ciphers_oper_only
,
531 "TLS cipher strings are hidden in whois for non-opers",
534 "default_split_server_count",
536 &ConfigChannel
.default_split_server_count
,
537 "Startup value of SPLITNUM",
540 "default_split_user_count",
542 &ConfigChannel
.default_split_user_count
,
543 "Startup value of SPLITUSERS",
548 &ConfigChannel
.knock_delay
,
549 "Delay between a users KNOCK attempts"
552 "knock_delay_channel",
554 &ConfigChannel
.knock_delay_channel
,
555 "Delay between KNOCK attempts to a channel",
558 "kick_on_split_riding",
560 &ConfigChannel
.kick_on_split_riding
,
561 "Kick users riding splits to join +i or +k channels"
564 "disable_local_channels",
566 &ConfigChannel
.disable_local_channels
,
567 "Disable local channels (&channels)"
572 &ConfigChannel
.max_bans
,
573 "Total +b/e/I/q modes allowed in a channel",
578 &ConfigChannel
.max_bans_large
,
579 "Total +b/e/I/q modes allowed in a +L channel",
582 "max_chans_per_user",
584 &ConfigChannel
.max_chans_per_user
,
585 "Maximum number of channels a user can join",
588 "max_chans_per_user_large",
590 &ConfigChannel
.max_chans_per_user_large
,
591 "Maximum extended 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"
642 "opmod_send_statusmsg",
644 &ConfigChannel
.opmod_send_statusmsg
,
645 "Send messages to @#channel if affected by +z"
650 &ConfigServerHide
.disable_hidden
,
651 "Prevent servers from hiding themselves from a flattened /links",
656 &ConfigServerHide
.flatten_links
,
657 "Flatten /links list",
662 &ConfigServerHide
.hidden
,
663 "Hide this server from a flattened /links on remote servers",
668 &ConfigServerHide
.links_delay
,
671 /* --[ END OF TABLE ]---------------------------------------------- */
672 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
678 ** parv[1] = servername
681 m_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
683 static time_t last_used
= 0L;
685 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
687 /* safe enough to give this on a local connect only */
688 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
689 me
.name
, source_p
->name
, "INFO");
690 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
694 last_used
= rb_current_time();
696 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
701 send_info_text(source_p
);
702 send_birthdate_online_time(source_p
);
704 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
709 ** parv[1] = servername
712 mo_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
714 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
717 send_info_text(source_p
);
721 send_conf_options(source_p
);
722 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
726 send_birthdate_online_time(source_p
);
728 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
735 * inputs - client pointer to send info text to
737 * side effects - info text is sent to client
740 send_info_text(struct Client
*source_p
)
742 const char **text
= infotext
;
746 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
749 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
753 * send_birthdate_online_time
755 * inputs - client pointer to send to
757 * side effects - birthdate and online time are sent
760 send_birthdate_online_time(struct Client
*source_p
)
762 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
763 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
764 get_id(&me
, source_p
), RPL_INFO
,
765 get_id(source_p
, source_p
), creation
, generation
);
767 sendto_one(source_p
, ":%s %d %s :On-line since %s",
768 get_id(&me
, source_p
), RPL_INFO
,
769 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
775 * inputs - client pointer to send to
777 * side effects - send config options to client
780 send_conf_options(struct Client
*source_p
)
786 * Now send them a list of all our configuration options
787 * (mostly from defaults.h)
789 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
791 if(infoptr
->intvalue
)
793 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
794 get_id(&me
, source_p
), RPL_INFO
,
795 get_id(source_p
, source_p
),
796 infoptr
->name
, infoptr
->intvalue
,
801 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
802 get_id(&me
, source_p
), RPL_INFO
,
803 get_id(source_p
, source_p
),
804 infoptr
->name
, infoptr
->strvalue
,
810 * Parse the info_table[] and do the magic.
812 for (i
= 0; info_table
[i
].name
; i
++)
814 switch (info_table
[i
].output_type
)
817 * For "char *" references
821 char *option
= *((char **) info_table
[i
].option
);
823 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
824 get_id(&me
, source_p
), RPL_INFO
,
825 get_id(source_p
, source_p
),
827 option
? option
: "NONE",
828 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
833 * For "char foo[]" references
835 case OUTPUT_STRING_PTR
:
837 char *option
= (char *) info_table
[i
].option
;
839 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
840 get_id(&me
, source_p
), RPL_INFO
,
841 get_id(source_p
, source_p
),
843 EmptyString(option
) ? "NONE" : option
,
844 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
849 * Output info_table[i].option as a decimal value.
853 int option
= *((int *) info_table
[i
].option
);
855 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
856 get_id(&me
, source_p
), RPL_INFO
,
857 get_id(source_p
, source_p
),
860 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
866 * Output info_table[i].option as "ON" or "OFF"
870 int option
= *((int *) info_table
[i
].option
);
872 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
873 get_id(&me
, source_p
), RPL_INFO
,
874 get_id(source_p
, source_p
),
876 option
? "ON" : "OFF",
877 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
882 * Output info_table[i].option as "YES" or "NO"
884 case OUTPUT_BOOLEAN_YN
:
886 int option
= *((int *) info_table
[i
].option
);
888 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
889 get_id(&me
, source_p
), RPL_INFO
,
890 get_id(source_p
, source_p
),
892 option
? "YES" : "NO",
893 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
898 case OUTPUT_BOOLEAN2
:
900 int option
= *((int *) info_table
[i
].option
);
902 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
903 me
.name
, RPL_INFO
, source_p
->name
,
905 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
906 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
907 } /* switch (info_table[i].output_type) */
912 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
913 ** in order for it to show up properly to opers who issue INFO
916 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
921 * input - pointer to client
923 * side effects - hook doing_info is called
926 info_spy(struct Client
*source_p
)
930 hd
.client
= source_p
;
931 hd
.arg1
= hd
.arg2
= NULL
;
933 call_hook(doing_info_hook
, &hd
);