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
40 #include "s_newconf.h"
42 static const char info_desc
[] =
43 "Provides the INFO command for retrieving server copyright, credits, and other info";
45 static void send_conf_options(struct Client
*source_p
);
46 static void send_birthdate_online_time(struct Client
*source_p
);
47 static void send_info_text(struct Client
*source_p
);
48 static void info_spy(struct Client
*);
50 static void m_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
51 static void mo_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
53 struct Message info_msgtab
= {
55 {mg_unreg
, {m_info
, 0}, {mo_info
, 0}, mg_ignore
, mg_ignore
, {mo_info
, 0}}
60 mapi_clist_av1 info_clist
[] = { &info_msgtab
, NULL
};
61 mapi_hlist_av1 info_hlist
[] = {
62 { "doing_info", &doing_info_hook
},
66 DECLARE_MODULE_AV2(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, NULL
, NULL
, info_desc
);
68 enum info_output_type
{
69 OUTPUT_STRING
, /* Output option as %s w/ dereference */
70 OUTPUT_STRING_PTR
, /* Output option as %s w/out deference */
71 OUTPUT_DECIMAL
, /* Output option as decimal (%d) */
72 OUTPUT_BOOLEAN
, /* Output option as "ON" or "OFF" */
73 OUTPUT_BOOLEAN_YN
, /* Output option as "YES" or "NO" */
74 OUTPUT_INTBOOL
, /* BOOLEAN encoded as an int */
75 OUTPUT_INTBOOL_YN
, /* BOOLEAN_YN encoded as an int */
76 OUTPUT_YESNOMASK
, /* Output option as "YES/NO/MASKED" */
77 OUTPUT_STATSL
, /* Output as "YES/NO/SELF" */
80 #define INFO_STRING(ptr) OUTPUT_STRING, .option.string_p = (ptr)
81 #define INFO_STRING_PTR(ptr) OUTPUT_STRING_PTR, .option.string = (ptr)
82 #define INFO_BOOLEAN(ptr) OUTPUT_BOOLEAN, .option.bool_ = (ptr)
83 #define INFO_BOOLEAN_YN(ptr) OUTPUT_BOOLEAN_YN, .option.bool_ = (ptr)
84 #define INFO_INTBOOL(ptr) OUTPUT_INTBOOL, .option.int_ = (ptr)
85 #define INFO_INTBOOL_YN(ptr) OUTPUT_INTBOOL_YN, .option.int_ = (ptr)
86 #define INFO_YESNOMASK(ptr) OUTPUT_YESNOMASK, .option.int_ = (ptr)
87 #define INFO_DECIMAL(ptr) OUTPUT_DECIMAL, .option.int_ = (ptr)
88 #define INFO_STATSL(ptr) OUTPUT_STATSL, .option.statsl = (ptr)
94 enum info_output_type output_type
;
99 char *const *string_p
;
101 const enum stats_l_oper_only
*statsl
;
106 static struct InfoStruct info_table
[] = {
109 "opers_see_all_users",
110 "Farconnect notices available or operspy accountability limited",
111 INFO_BOOLEAN(&opers_see_all_users
)
115 "Max number connections",
116 INFO_DECIMAL(&maxconnections
),
120 "NICK flood protection",
121 INFO_INTBOOL(&ConfigFileEntry
.anti_nick_flood
),
124 "anti_spam_exit_message_time",
125 "Duration a client must be connected for to have an exit message",
126 INFO_DECIMAL(&ConfigFileEntry
.anti_spam_exit_message_time
),
130 "Minimum delay between notifying UMODE +g users of messages",
131 INFO_DECIMAL(&ConfigFileEntry
.caller_id_wait
),
135 "Prepend 'Quit:' to user QUIT messages",
136 INFO_INTBOOL(&ConfigFileEntry
.client_exit
),
139 "client_flood_max_lines",
140 "Number of lines before a client Excess Flood's",
141 INFO_DECIMAL(&ConfigFileEntry
.client_flood_max_lines
),
144 "client_flood_burst_rate",
145 "Maximum lines per second during flood grace period",
146 INFO_DECIMAL(&ConfigFileEntry
.client_flood_burst_rate
),
149 "client_flood_burst_max",
150 "Number of lines to process at once before delaying",
151 INFO_DECIMAL(&ConfigFileEntry
.client_flood_burst_max
),
154 "client_flood_message_num",
155 "Number of messages to allow per client_flood_message_time outside of burst",
156 INFO_DECIMAL(&ConfigFileEntry
.client_flood_message_num
),
159 "client_flood_message_time",
160 "Time to allow per client_flood_message_num outside of burst",
161 INFO_DECIMAL(&ConfigFileEntry
.client_flood_message_time
),
164 "post_registration_delay",
165 "Time to wait before processing commands from a new client",
166 INFO_DECIMAL(&ConfigFileEntry
.post_registration_delay
),
170 "Connect timeout for connections to servers",
171 INFO_DECIMAL(&ConfigFileEntry
.connect_timeout
),
174 "default_ident_timeout",
175 "Amount of time the server waits for ident responses from clients",
176 INFO_DECIMAL(&ConfigFileEntry
.default_ident_timeout
),
179 "default_floodcount",
180 "Startup value of FLOODCOUNT",
181 INFO_DECIMAL(&ConfigFileEntry
.default_floodcount
),
184 "default_adminstring",
185 "Default adminstring at startup.",
186 INFO_STRING(&ConfigFileEntry
.default_adminstring
),
189 "default_operstring",
190 "Default operstring at startup.",
191 INFO_STRING(&ConfigFileEntry
.default_operstring
),
195 "String shown in whois for opered services.",
196 INFO_STRING(&ConfigFileEntry
.servicestring
),
200 "Message to quit users with if this server is draining.",
201 INFO_STRING(&ConfigFileEntry
.drain_reason
),
205 "Controls whether auth checking is disabled or not",
206 INFO_INTBOOL_YN(&ConfigFileEntry
.disable_auth
),
209 "disable_fake_channels",
210 "Controls whether bold etc are disabled for JOIN",
211 INFO_INTBOOL_YN(&ConfigFileEntry
.disable_fake_channels
),
215 "Number of permissible dots in an ident",
216 INFO_DECIMAL(&ConfigFileEntry
.dots_in_ident
),
219 "failed_oper_notice",
220 "Inform opers if someone /oper's with the wrong password",
221 INFO_INTBOOL(&ConfigFileEntry
.failed_oper_notice
),
226 INFO_STRING(&ConfigFileEntry
.fname_userlog
),
230 "Failed user log file",
231 INFO_STRING(&ConfigFileEntry
.fname_fuserlog
),
237 INFO_STRING(&ConfigFileEntry
.fname_operlog
),
241 "Failed operator log file",
242 INFO_STRING(&ConfigFileEntry
.fname_foperlog
),
246 "Server connect/disconnect log file",
247 INFO_STRING(&ConfigFileEntry
.fname_serverlog
),
252 INFO_STRING(&ConfigFileEntry
.fname_killlog
),
256 "KLINE etc log file",
257 INFO_STRING(&ConfigFileEntry
.fname_klinelog
),
262 INFO_STRING(&ConfigFileEntry
.fname_operspylog
),
267 INFO_STRING(&ConfigFileEntry
.fname_ioerrorlog
),
271 "Send out certain server notices globally",
272 INFO_INTBOOL_YN(&ConfigFileEntry
.global_snotices
),
275 "hide_error_messages",
276 "Hide ERROR messages coming from servers",
277 INFO_YESNOMASK(&ConfigFileEntry
.hide_error_messages
),
281 "Hide IPs of spoofed users",
282 INFO_INTBOOL_YN(&ConfigFileEntry
.hide_spoof_ips
),
286 "K-lined clients sign off with this reason",
287 INFO_STRING(&ConfigFileEntry
.kline_reason
),
291 "Display D-line reason to client on disconnect",
292 INFO_INTBOOL_YN(&ConfigFileEntry
.dline_with_reason
),
296 "Display K-line reason to client on disconnect",
297 INFO_INTBOOL_YN(&ConfigFileEntry
.kline_with_reason
),
300 "hide_tkdline_duration",
301 "Hide \"Temporary K-line 123 min.\" from user K/D-lline reasons",
302 INFO_INTBOOL_YN(&ConfigFileEntry
.hide_tkdline_duration
),
306 "Maximum nicknames on accept list",
307 INFO_DECIMAL(&ConfigFileEntry
.max_accept
),
311 "NICK change threshold setting",
312 INFO_DECIMAL(&ConfigFileEntry
.max_nick_changes
),
316 "NICK flood protection time interval",
317 INFO_DECIMAL(&ConfigFileEntry
.max_nick_time
),
321 "The maximum number of PRIVMSG/NOTICE targets",
322 INFO_DECIMAL(&ConfigFileEntry
.max_targets
),
326 "Minimum non-wildcard chars in K lines",
327 INFO_DECIMAL(&ConfigFileEntry
.min_nonwildcard
),
330 "min_nonwildcard_simple",
331 "Minimum non-wildcard chars in xlines/resvs",
332 INFO_DECIMAL(&ConfigFileEntry
.min_nonwildcard_simple
),
337 INFO_STRING(&ServerInfo
.network_name
),
341 "Delay nicks are locked for on split",
342 INFO_DECIMAL(&ConfigFileEntry
.nick_delay
),
346 "Disable flood control for operators",
347 INFO_INTBOOL(&ConfigFileEntry
.no_oper_flood
),
350 "non_redundant_klines",
351 "Check for and disallow redundant K-lines",
352 INFO_INTBOOL(&ConfigFileEntry
.non_redundant_klines
),
355 "operspy_admin_only",
356 "Send +Z operspy notices to admins only",
357 INFO_INTBOOL(&ConfigFileEntry
.operspy_admin_only
),
360 "operspy_dont_care_user_info",
361 "Remove accountability and some '!' requirement from non-channel operspy",
362 INFO_INTBOOL(&ConfigFileEntry
.operspy_dont_care_user_info
),
366 "Minimum delay between uses of certain commands",
367 INFO_DECIMAL(&ConfigFileEntry
.pace_wait
),
371 "Minimum delay between less intensive commands",
372 INFO_DECIMAL(&ConfigFileEntry
.pace_wait_simple
),
376 "Require ping cookies to connect",
377 INFO_INTBOOL(&ConfigFileEntry
.ping_cookie
),
380 "reject_after_count",
381 "Client rejection threshold setting",
382 INFO_DECIMAL(&ConfigFileEntry
.reject_after_count
),
386 "Client rejection time interval",
387 INFO_DECIMAL(&ConfigFileEntry
.reject_ban_time
),
391 "Client rejection cache duration",
392 INFO_DECIMAL(&ConfigFileEntry
.reject_duration
),
396 "Do not show MOTD; only tell clients they should read it",
397 INFO_INTBOOL_YN(&ConfigFileEntry
.short_motd
),
401 "STATS e output is disabled",
402 INFO_INTBOOL_YN(&ConfigFileEntry
.stats_e_disabled
),
406 "STATS C output is only shown to operators",
407 INFO_INTBOOL_YN(&ConfigFileEntry
.stats_c_oper_only
),
411 "STATS I output is only shown to operators",
412 INFO_YESNOMASK(&ConfigFileEntry
.stats_i_oper_only
),
416 "STATS K output is only shown to operators",
417 INFO_YESNOMASK(&ConfigFileEntry
.stats_k_oper_only
),
421 "STATS l/L output is only shown to operators",
422 INFO_STATSL(&ConfigFileEntry
.stats_l_oper_only
),
426 "STATS O output is only shown to operators",
427 INFO_INTBOOL_YN(&ConfigFileEntry
.stats_o_oper_only
),
431 "STATS P is only shown to operators",
432 INFO_INTBOOL_YN(&ConfigFileEntry
.stats_P_oper_only
),
436 "STATS Y is only shown to operators",
437 INFO_INTBOOL_YN(&ConfigFileEntry
.stats_y_oper_only
),
441 "Connection throttle threshold",
442 INFO_DECIMAL(&ConfigFileEntry
.throttle_count
),
446 "Connection throttle duration",
447 INFO_DECIMAL(&ConfigFileEntry
.throttle_duration
),
450 "tkline_expire_notices",
451 "Notices given to opers when tklines expire",
452 INFO_INTBOOL(&ConfigFileEntry
.tkline_expire_notices
),
456 "Maximum permitted TS delta from another server",
457 INFO_DECIMAL(&ConfigFileEntry
.ts_max_delta
),
461 "Maximum permitted TS delta before displaying a warning",
462 INFO_DECIMAL(&ConfigFileEntry
.ts_warn_delta
),
466 "Display warning if connecting server lacks connect block",
467 INFO_INTBOOL(&ConfigFileEntry
.warn_no_nline
),
470 "use_propagated_bans",
471 "KLINE sets fully propagated bans",
472 INFO_INTBOOL(&ConfigFileEntry
.use_propagated_bans
),
475 "max_ratelimit_tokens",
476 "The maximum number of tokens that can be accumulated for executing rate-limited commands",
477 INFO_DECIMAL(&ConfigFileEntry
.max_ratelimit_tokens
),
481 "The minimum time between aways",
482 INFO_DECIMAL(&ConfigFileEntry
.away_interval
),
485 "tls_ciphers_oper_only",
486 "TLS cipher strings are hidden in whois for non-opers",
487 INFO_INTBOOL_YN(&ConfigFileEntry
.tls_ciphers_oper_only
),
490 "default_split_server_count",
491 "Startup value of SPLITNUM",
492 INFO_DECIMAL(&ConfigChannel
.default_split_server_count
),
495 "default_split_user_count",
496 "Startup value of SPLITUSERS",
497 INFO_DECIMAL(&ConfigChannel
.default_split_user_count
),
501 "Delay between a users KNOCK attempts",
502 INFO_DECIMAL(&ConfigChannel
.knock_delay
),
505 "knock_delay_channel",
506 "Delay between KNOCK attempts to a channel",
507 INFO_DECIMAL(&ConfigChannel
.knock_delay_channel
),
510 "kick_on_split_riding",
511 "Kick users riding splits to join +i or +k channels",
512 INFO_INTBOOL_YN(&ConfigChannel
.kick_on_split_riding
),
515 "disable_local_channels",
516 "Disable local channels (&channels)",
517 INFO_INTBOOL_YN(&ConfigChannel
.disable_local_channels
),
521 "Total +b/e/I/q modes allowed in a channel",
522 INFO_DECIMAL(&ConfigChannel
.max_bans
),
526 "Total +b/e/I/q modes allowed in a +L channel",
527 INFO_DECIMAL(&ConfigChannel
.max_bans_large
),
530 "max_chans_per_user",
531 "Maximum number of channels a user can join",
532 INFO_DECIMAL(&ConfigChannel
.max_chans_per_user
),
535 "max_chans_per_user_large",
536 "Maximum extended number of channels a user can join",
537 INFO_DECIMAL(&ConfigChannel
.max_chans_per_user_large
),
540 "no_create_on_split",
541 "Disallow creation of channels when split",
542 INFO_INTBOOL_YN(&ConfigChannel
.no_create_on_split
),
546 "Disallow joining channels when split",
547 INFO_INTBOOL_YN(&ConfigChannel
.no_join_on_split
),
550 "only_ascii_channels",
551 "Controls whether non-ASCII is disabled for JOIN",
552 INFO_INTBOOL_YN(&ConfigChannel
.only_ascii_channels
),
556 "Enable chanmode +e (ban exceptions)",
557 INFO_INTBOOL_YN(&ConfigChannel
.use_except
),
561 "Enable chanmode +I (invite exceptions)",
562 INFO_INTBOOL_YN(&ConfigChannel
.use_invex
),
566 "Enable chanmode +f (channel forwarding)",
567 INFO_INTBOOL_YN(&ConfigChannel
.use_forward
),
572 INFO_INTBOOL_YN(&ConfigChannel
.use_knock
),
576 "Force-part local users on channel RESV",
577 INFO_INTBOOL_YN(&ConfigChannel
.resv_forcepart
),
580 "opmod_send_statusmsg",
581 "Send messages to @#channel if affected by +z",
582 INFO_INTBOOL_YN(&ConfigChannel
.opmod_send_statusmsg
),
586 "Hide all opers from unprivileged users",
587 INFO_INTBOOL_YN(&ConfigFileEntry
.hide_opers
),
590 "hide_opers_in_whois",
591 "Don't send RPL_WHOISOPERATOR to non-opers",
592 INFO_INTBOOL_YN(&ConfigFileEntry
.hide_opers_in_whois
),
596 "Prevent servers from hiding themselves from a flattened /links",
597 INFO_INTBOOL_YN(&ConfigServerHide
.disable_hidden
),
601 "Flatten /links list",
602 INFO_INTBOOL_YN(&ConfigServerHide
.flatten_links
),
606 "Hide this server from a flattened /links on remote servers",
607 INFO_INTBOOL_YN(&ConfigServerHide
.hidden
),
611 "Links rehash delay",
612 INFO_DECIMAL(&ConfigServerHide
.links_delay
),
616 "Require TLS to become an oper",
617 INFO_INTBOOL_YN(&ConfigFileEntry
.oper_secure_only
),
620 { NULL
, NULL
, 0, { NULL
} },
626 ** parv[1] = servername
629 m_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
631 static time_t last_used
= 0L;
633 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
635 /* safe enough to give this on a local connect only */
636 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
637 me
.name
, source_p
->name
, "INFO");
638 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
642 last_used
= rb_current_time();
644 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
649 send_info_text(source_p
);
650 send_birthdate_online_time(source_p
);
652 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
657 ** parv[1] = servername
660 mo_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
662 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
665 send_info_text(source_p
);
667 if(IsOperGeneral(source_p
))
669 send_conf_options(source_p
);
670 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
674 send_birthdate_online_time(source_p
);
676 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
683 * inputs - client pointer to send info text to
685 * side effects - info text is sent to client
688 send_info_text(struct Client
*source_p
)
690 const char **text
= infotext
;
694 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
697 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
701 * send_birthdate_online_time
703 * inputs - client pointer to send to
705 * side effects - birthdate and online time are sent
708 send_birthdate_online_time(struct Client
*source_p
)
710 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
711 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
712 get_id(&me
, source_p
), RPL_INFO
,
713 get_id(source_p
, source_p
), creation
, generation
);
715 sendto_one(source_p
, ":%s %d %s :On-line since %s",
716 get_id(&me
, source_p
), RPL_INFO
,
717 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
723 * inputs - client pointer to send to
725 * side effects - send config options to client
728 send_conf_options(struct Client
*source_p
)
734 * Now send them a list of all our configuration options
735 * (mostly from defaults.h)
737 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
739 if(infoptr
->intvalue
)
741 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
742 get_id(&me
, source_p
), RPL_INFO
,
743 get_id(source_p
, source_p
),
744 infoptr
->name
, infoptr
->intvalue
,
749 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
750 get_id(&me
, source_p
), RPL_INFO
,
751 get_id(source_p
, source_p
),
752 infoptr
->name
, infoptr
->strvalue
,
758 * Parse the info_table[] and do the magic.
760 for (i
= 0; info_table
[i
].name
; i
++)
762 static char opt_buf
[BUFSIZE
];
763 const char *opt_value
= opt_buf
;
766 switch (info_table
[i
].output_type
)
770 const char *option
= *info_table
[i
].option
.string_p
;
771 opt_value
= option
!= NULL
? option
: "NONE";
774 case OUTPUT_STRING_PTR
:
776 const char *option
= info_table
[i
].option
.string
;
777 opt_value
= option
!= NULL
? option
: "NONE";
782 int option
= *info_table
[i
].option
.int_
;
783 snprintf(opt_buf
, sizeof opt_buf
, "%d", option
);
788 bool option
= *info_table
[i
].option
.bool_
;
789 opt_value
= option
? "ON" : "OFF";
792 case OUTPUT_BOOLEAN_YN
:
794 bool option
= *info_table
[i
].option
.bool_
;
795 opt_value
= option
? "YES" : "NO";
798 case OUTPUT_YESNOMASK
:
800 int option
= *info_table
[i
].option
.int_
;
801 opt_value
= option
== 0 ? "NO" :
802 option
== 1 ? "MASK" :
808 bool option
= *info_table
[i
].option
.int_
;
809 opt_value
= option
? "ON" : "OFF";
812 case OUTPUT_INTBOOL_YN
:
814 bool option
= *info_table
[i
].option
.int_
;
815 opt_value
= option
? "YES" : "NO";
820 enum stats_l_oper_only option
= *info_table
[i
].option
.statsl
;
821 opt_value
= option
== STATS_L_OPER_ONLY_NO
? "NO" :
822 option
== STATS_L_OPER_ONLY_SELF
? "SELF" :
828 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
829 get_id(&me
, source_p
), RPL_INFO
,
830 get_id(source_p
, source_p
),
833 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
837 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
838 ** in order for it to show up properly to opers who issue INFO
841 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
846 * input - pointer to client
848 * side effects - hook doing_info is called
851 info_spy(struct Client
*source_p
)
855 hd
.client
= source_p
;
856 hd
.arg1
= hd
.arg2
= NULL
;
858 call_hook(doing_info_hook
, &hd
);