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 '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
.default_operhost
,
158 "Default vhost for operators to receive upon opering up.",
163 &ConfigFileEntry
.servicestring
,
164 "String shown in whois for opered services.",
169 &ConfigFileEntry
.disable_auth
,
170 "Controls whether auth checking is disabled or not"
173 "disable_fake_channels",
175 &ConfigFileEntry
.disable_fake_channels
,
176 "Controls whether bold etc are disabled for JOIN"
181 &ConfigFileEntry
.dots_in_ident
,
182 "Number of permissable dots in an ident"
185 "expire_override_time",
187 &ConfigFileEntry
.expire_override_time
,
188 "Period of time after which to unset user mode +p"
191 "failed_oper_notice",
193 &ConfigFileEntry
.failed_oper_notice
,
194 "Inform opers if someone /oper's with the wrong password"
199 &ConfigFileEntry
.fname_userlog
,
205 &ConfigFileEntry
.fname_fuserlog
,
206 "Failed user log file"
212 &ConfigFileEntry
.fname_operlog
,
218 &ConfigFileEntry
.fname_foperlog
,
219 "Failed operator log file"
224 &ConfigFileEntry
.fname_serverlog
,
225 "Server connect/disconnect log file"
230 &ConfigFileEntry
.fname_klinelog
,
236 &ConfigFileEntry
.fname_operspylog
,
242 &ConfigFileEntry
.fname_ioerrorlog
,
248 &ConfigFileEntry
.global_snotices
,
249 "Send out certain server notices globally"
252 "hide_error_messages",
254 &ConfigFileEntry
.hide_error_messages
,
255 "Hide ERROR messages coming from servers"
260 &ConfigFileEntry
.hide_spoof_ips
,
261 "Hide IPs of spoofed users"
272 &ConfigFileEntry
.kline_delay
,
273 "Duration of time to delay kline checking"
278 &ConfigFileEntry
.kline_reason
,
279 "K-lined clients sign off with this reason"
284 &ConfigFileEntry
.dline_with_reason
,
285 "Display D-line reason to client on disconnect"
290 &ConfigFileEntry
.kline_with_reason
,
291 "Display K-line reason to client on disconnect"
296 &ConfigFileEntry
.max_accept
,
297 "Maximum nicknames on accept list",
302 &ConfigFileEntry
.max_nick_changes
,
303 "NICK change threshhold setting"
308 &ConfigFileEntry
.max_nick_time
,
309 "NICK flood protection time interval"
314 &ConfigFileEntry
.max_targets
,
315 "The maximum number of PRIVMSG/NOTICE targets"
320 &ConfigFileEntry
.min_nonwildcard
,
321 "Minimum non-wildcard chars in K lines",
324 "min_nonwildcard_simple",
326 &ConfigFileEntry
.min_nonwildcard_simple
,
327 "Minimum non-wildcard chars in xlines/resvs",
332 &ServerInfo
.network_name
,
338 &ServerInfo
.network_desc
,
339 "Network description"
344 &ConfigChannel
.autochanmodes
,
345 "Channelmodes set on channel creation"
350 &ConfigChannel
.exemptchanops
,
351 "Channelmodes that chanops are exempt from"
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"
384 "secret_channels_in_whois",
386 &ConfigFileEntry
.secret_channels_in_whois
,
387 "Defines whether secret channels are always shown in whois to opers with oper:spy priv."
392 &ConfigFileEntry
.pace_wait
,
393 "Minimum delay between uses of certain commands"
398 &ConfigFileEntry
.pace_wait_simple
,
399 "Minimum delay between less intensive commands"
404 &ConfigFileEntry
.ping_cookie
,
405 "Require ping cookies to connect",
408 "reject_after_count",
410 &ConfigFileEntry
.reject_after_count
,
411 "Client rejection threshold setting",
416 &ConfigFileEntry
.reject_ban_time
,
417 "Client rejection time interval",
422 &ConfigFileEntry
.reject_duration
,
423 "Client rejection cache duration",
428 &ConfigFileEntry
.short_motd
,
429 "Do not show MOTD; only tell clients they should read it"
434 &ConfigFileEntry
.stats_e_disabled
,
435 "STATS e output is disabled",
440 &ConfigFileEntry
.stats_c_oper_only
,
441 "STATS C output is only shown to operators",
446 &ConfigFileEntry
.stats_h_oper_only
,
447 "STATS H output is only shown to operators",
452 &ConfigFileEntry
.stats_i_oper_only
,
453 "STATS I output is only shown to operators",
458 &ConfigFileEntry
.stats_k_oper_only
,
459 "STATS K output is only shown to operators",
464 &ConfigFileEntry
.stats_o_oper_only
,
465 "STATS O output is only shown to operators",
470 &ConfigFileEntry
.stats_P_oper_only
,
471 "STATS P is only shown to operators",
476 &ConfigFileEntry
.stats_y_oper_only
,
477 "STATS Y is only shown to operators",
482 &ConfigFileEntry
.throttle_count
,
483 "Connection throttle threshold",
488 &ConfigFileEntry
.throttle_duration
,
489 "Connection throttle duration",
492 "tkline_expire_notices",
494 &ConfigFileEntry
.tkline_expire_notices
,
495 "Notices given to opers when tklines expire"
500 &ConfigFileEntry
.ts_max_delta
,
501 "Maximum permitted TS delta from another server"
506 &ConfigFileEntry
.ts_warn_delta
,
507 "Maximum permitted TS delta before displaying a warning"
512 &ConfigFileEntry
.warn_no_nline
,
513 "Display warning if connecting server lacks N-line"
516 "default_split_server_count",
518 &ConfigChannel
.default_split_server_count
,
519 "Startup value of SPLITNUM",
522 "default_split_user_count",
524 &ConfigChannel
.default_split_user_count
,
525 "Startup value of SPLITUSERS",
530 &ConfigChannel
.knock_delay
,
531 "Delay between a users KNOCK attempts"
534 "knock_delay_channel",
536 &ConfigChannel
.knock_delay_channel
,
537 "Delay between KNOCK attempts to a channel",
540 "kick_on_split_riding",
542 &ConfigChannel
.kick_on_split_riding
,
543 "Kick users riding splits to join +i or +k channels"
548 &ConfigChannel
.max_bans
,
549 "Total +b/e/I/q modes allowed in a channel",
554 &ConfigChannel
.max_bans_large
,
555 "Total +b/e/I/q modes allowed in a +L channel",
558 "max_chans_per_user",
560 &ConfigChannel
.max_chans_per_user
,
561 "Maximum number of channels a user can join",
564 "no_create_on_split",
566 &ConfigChannel
.no_create_on_split
,
567 "Disallow creation of channels when split",
572 &ConfigChannel
.no_join_on_split
,
573 "Disallow joining channels when split",
576 "only_ascii_channels",
578 &ConfigChannel
.only_ascii_channels
,
579 "Controls whether non-ASCII is disabled for JOIN"
584 &ConfigChannel
.cycle_host_change
,
585 "Controls if when a users' host changes, they cycle channels",
590 &ConfigChannel
.host_in_topic
,
591 "Defines whether a topicsetters host or just nick is shown on TOPIC",
596 &ConfigChannel
.use_halfop
,
597 "Enable chanmode +h (halfop)",
602 &ConfigChannel
.use_owner
,
603 "Enable chanmode +a (owner)",
608 &ConfigChannel
.use_except
,
609 "Enable chanmode +e (ban exceptions)",
614 &ConfigChannel
.use_invex
,
615 "Enable chanmode +I (invite exceptions)",
620 &ConfigChannel
.use_forward
,
621 "Enable chanmode +f (channel forwarding)",
626 &ConfigChannel
.use_knock
,
630 "use_local_channels",
632 &ConfigChannel
.use_local_channels
,
633 "Enable local channels (&channels)"
638 { &ConfigChannel
.resv_forcepart
},
639 "Force-part local users on channel RESV"
642 "kick_no_rejoin_time",
644 { &ConfigChannel
.kick_no_rejoin_time
},
645 "The amount of time that a user cannot rejoin a +J channel for after being kicked."
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 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
));
710 ** parv[1] = servername
713 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
715 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
718 send_info_text(source_p
);
722 send_conf_options(source_p
);
723 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
727 send_birthdate_online_time(source_p
);
729 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
738 * inputs - client pointer to send info text to
740 * side effects - info text is sent to client
743 send_info_text(struct Client
*source_p
)
745 const char **text
= infotext
;
749 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
752 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
756 * send_birthdate_online_time
758 * inputs - client pointer to send to
760 * side effects - birthdate and online time are sent
763 send_birthdate_online_time(struct Client
*source_p
)
765 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
766 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
767 get_id(&me
, source_p
), RPL_INFO
,
768 get_id(source_p
, source_p
), creation
, generation
);
770 sendto_one(source_p
, ":%s %d %s :On-line since %s",
771 get_id(&me
, source_p
), RPL_INFO
,
772 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
778 * inputs - client pointer to send to
780 * side effects - send config options to client
783 send_conf_options(struct Client
*source_p
)
789 * Now send them a list of all our configuration options
790 * (mostly from config.h)
792 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
794 if(infoptr
->intvalue
)
796 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
797 get_id(&me
, source_p
), RPL_INFO
,
798 get_id(source_p
, source_p
),
799 infoptr
->name
, infoptr
->intvalue
,
804 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
805 get_id(&me
, source_p
), RPL_INFO
,
806 get_id(source_p
, source_p
),
807 infoptr
->name
, infoptr
->strvalue
,
813 * Parse the info_table[] and do the magic.
815 for (i
= 0; info_table
[i
].name
; i
++)
817 switch (info_table
[i
].output_type
)
820 * For "char *" references
824 char *option
= *((char **) info_table
[i
].option
);
826 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
827 get_id(&me
, source_p
), RPL_INFO
,
828 get_id(source_p
, source_p
),
830 option
? option
: "NONE",
831 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
836 * For "char foo[]" references
838 case OUTPUT_STRING_PTR
:
840 char *option
= (char *) info_table
[i
].option
;
842 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
843 get_id(&me
, source_p
), RPL_INFO
,
844 get_id(source_p
, source_p
),
846 EmptyString(option
) ? "NONE" : option
,
847 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
852 * Output info_table[i].option as a decimal value.
856 int option
= *((int *) info_table
[i
].option
);
858 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
859 get_id(&me
, source_p
), RPL_INFO
,
860 get_id(source_p
, source_p
),
863 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
869 * Output info_table[i].option as "ON" or "OFF"
873 int option
= *((int *) info_table
[i
].option
);
875 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
876 get_id(&me
, source_p
), RPL_INFO
,
877 get_id(source_p
, source_p
),
879 option
? "ON" : "OFF",
880 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
885 * Output info_table[i].option as "YES" or "NO"
887 case OUTPUT_BOOLEAN_YN
:
889 int option
= *((int *) info_table
[i
].option
);
891 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
892 get_id(&me
, source_p
), RPL_INFO
,
893 get_id(source_p
, source_p
),
895 option
? "YES" : "NO",
896 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
901 case OUTPUT_BOOLEAN2
:
903 int option
= *((int *) info_table
[i
].option
);
905 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
906 me
.name
, RPL_INFO
, source_p
->name
,
908 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
909 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
910 } /* switch (info_table[i].output_type) */
915 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
916 ** in order for it to show up properly to opers who issue INFO
919 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
924 * input - pointer to client
926 * side effects - hook doing_info is called
929 info_spy(struct Client
*source_p
)
933 hd
.client
= source_p
;
934 hd
.arg1
= hd
.arg2
= NULL
;
936 call_hook(doing_info_hook
, &hd
);