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
43 static void send_conf_options(struct Client
*source_p
);
44 static void send_birthdate_online_time(struct Client
*source_p
);
45 static void send_info_text(struct Client
*source_p
);
46 static void info_spy(struct Client
*);
48 static int m_info(struct Client
*, struct Client
*, int, const char **);
49 static int mo_info(struct Client
*, struct Client
*, int, const char **);
51 struct Message info_msgtab
= {
52 "INFO", 0, 0, 0, MFLG_SLOW
,
53 {mg_unreg
, {m_info
, 0}, {mo_info
, 0}, mg_ignore
, mg_ignore
, {mo_info
, 0}}
58 mapi_clist_av1 info_clist
[] = { &info_msgtab
, NULL
};
59 mapi_hlist_av1 info_hlist
[] = {
60 { "doing_info", &doing_info_hook
},
64 DECLARE_MODULE_AV1(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, "$Revision: 3396 $");
67 * jdc -- Structure for our configuration value table
71 const char *name
; /* Displayed variable name */
72 unsigned int output_type
; /* See below #defines */
73 void *option
; /* Pointer reference to the value */
74 const char *desc
; /* ASCII description of the variable */
76 /* Types for output_type in InfoStruct */
77 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
78 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
79 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
80 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
81 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
82 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
85 static struct InfoStruct info_table
[] = {
86 /* --[ START OF TABLE ]-------------------------------------------- */
88 "opers_see_all_users",
91 "Farconnect notices available or operspy accountability limited"
97 "Max number connections"
102 &ConfigFileEntry
.anti_nick_flood
,
103 "NICK flood protection"
106 "anti_spam_exit_message_time",
108 &ConfigFileEntry
.anti_spam_exit_message_time
,
109 "Duration a client must be connected for to have an exit message"
114 &ConfigFileEntry
.use_part_messages
,
115 "Whether or not the server should allow users to show messages on PART"
120 &ConfigFileEntry
.caller_id_wait
,
121 "Minimum delay between notifying UMODE +g users of messages"
126 &ConfigFileEntry
.client_exit
,
127 "Prepend 'Client Exit:' to user QUIT messages"
132 &ConfigFileEntry
.client_flood
,
133 "Number of lines before a client Excess Flood's",
138 &ConfigFileEntry
.connect_timeout
,
139 "Connect timeout for connections to servers"
142 "default_ident_timeout",
144 &ConfigFileEntry
.default_ident_timeout
,
145 "Amount of time the server waits for ident responses from clients",
148 "default_floodcount",
150 &ConfigFileEntry
.default_floodcount
,
151 "Startup value of FLOODCOUNT",
154 "hide_channel_below_users",
156 &ConfigFileEntry
.hide_channel_below_users
,
157 "Hide channels below this many users in standard /LIST output",
160 "default_adminstring",
162 &ConfigFileEntry
.default_adminstring
,
163 "Default adminstring at startup.",
166 "default_operstring",
168 &ConfigFileEntry
.default_operstring
,
169 "Default operstring at startup.",
174 &ConfigFileEntry
.default_operhost
,
175 "Default vhost for operators to receive upon opering up.",
180 &ConfigFileEntry
.static_quit
,
181 "Quit message to show for all users.",
186 &ConfigFileEntry
.servicestring
,
187 "String shown in whois for opered services.",
192 &ConfigFileEntry
.disable_auth
,
193 "Controls whether auth checking is disabled or not"
196 "disable_fake_channels",
198 &ConfigFileEntry
.disable_fake_channels
,
199 "Controls whether bold etc are disabled for JOIN"
204 &ConfigFileEntry
.dots_in_ident
,
205 "Number of permissable dots in an ident"
208 "expire_override_time",
210 &ConfigFileEntry
.expire_override_time
,
211 "Period of time after which to unset user mode +p"
214 "failed_oper_notice",
216 &ConfigFileEntry
.failed_oper_notice
,
217 "Inform opers if someone /oper's with the wrong password"
222 &ConfigFileEntry
.fname_userlog
,
228 &ConfigFileEntry
.fname_fuserlog
,
229 "Failed user log file"
235 &ConfigFileEntry
.fname_operlog
,
241 &ConfigFileEntry
.fname_foperlog
,
242 "Failed operator log file"
247 &ConfigFileEntry
.fname_serverlog
,
248 "Server connect/disconnect log file"
253 &ConfigFileEntry
.fname_klinelog
,
259 &ConfigFileEntry
.fname_operspylog
,
265 &ConfigFileEntry
.fname_ioerrorlog
,
271 &ConfigFileEntry
.global_snotices
,
272 "Send out certain server notices globally"
275 "hide_error_messages",
277 &ConfigFileEntry
.hide_error_messages
,
278 "Hide ERROR messages coming from servers"
283 &ConfigFileEntry
.hide_spoof_ips
,
284 "Hide IPs of spoofed users"
295 &ConfigFileEntry
.kline_delay
,
296 "Duration of time to delay kline checking"
301 &ConfigFileEntry
.kline_reason
,
302 "K-lined clients sign off with this reason"
307 &ConfigFileEntry
.dline_with_reason
,
308 "Display D-line reason to client on disconnect"
313 &ConfigFileEntry
.kline_with_reason
,
314 "Display K-line reason to client on disconnect"
319 &ConfigFileEntry
.max_accept
,
320 "Maximum nicknames on accept list",
325 &ConfigFileEntry
.max_nick_changes
,
326 "NICK change threshhold setting"
331 &ConfigFileEntry
.max_nick_time
,
332 "NICK flood protection time interval"
337 &ConfigFileEntry
.max_targets
,
338 "The maximum number of PRIVMSG/NOTICE targets"
343 &ConfigFileEntry
.min_nonwildcard
,
344 "Minimum non-wildcard chars in K lines",
347 "min_nonwildcard_simple",
349 &ConfigFileEntry
.min_nonwildcard_simple
,
350 "Minimum non-wildcard chars in xlines/resvs",
355 &ServerInfo
.network_name
,
361 &ServerInfo
.network_desc
,
362 "Network description"
367 &ConfigChannel
.autochanmodes
,
368 "Channelmodes set on channel creation"
373 &ConfigChannel
.exemptchanops
,
374 "Channelmodes that chanops are exempt from"
379 &ConfigFileEntry
.nick_delay
,
380 "Delay nicks are locked for on split",
385 &ConfigFileEntry
.no_oper_flood
,
386 "Disable flood control for operators",
389 "true_no_oper_flood",
391 &ConfigFileEntry
.true_no_oper_flood
,
392 "Really disable flood control for opers, not just make it very high",
395 "non_redundant_klines",
397 &ConfigFileEntry
.non_redundant_klines
,
398 "Check for and disallow redundant K-lines"
401 "operspy_admin_only",
403 &ConfigFileEntry
.operspy_admin_only
,
404 "Send +Z operspy notices to admins only"
407 "operspy_dont_care_user_info",
409 &ConfigFileEntry
.operspy_dont_care_user_info
,
410 "Remove accountability and some '!' requirement from non-channel operspy"
413 "secret_channels_in_whois",
415 &ConfigFileEntry
.secret_channels_in_whois
,
416 "Defines whether secret channels are always shown in whois to opers with oper:spy priv."
421 &ConfigFileEntry
.pace_wait
,
422 "Minimum delay between uses of certain commands"
427 &ConfigFileEntry
.pace_wait_simple
,
428 "Minimum delay between less intensive commands"
433 &ConfigFileEntry
.ping_cookie
,
434 "Require ping cookies to connect",
437 "reject_after_count",
439 &ConfigFileEntry
.reject_after_count
,
440 "Client rejection threshold setting",
445 &ConfigFileEntry
.reject_ban_time
,
446 "Client rejection time interval",
451 &ConfigFileEntry
.reject_duration
,
452 "Client rejection cache duration",
457 &ConfigFileEntry
.short_motd
,
458 "Do not show MOTD; only tell clients they should read it"
463 &ConfigFileEntry
.stats_e_disabled
,
464 "STATS e output is disabled",
469 &ConfigFileEntry
.stats_c_oper_only
,
470 "STATS C output is only shown to operators",
475 &ConfigFileEntry
.stats_h_oper_only
,
476 "STATS H output is only shown to operators",
481 &ConfigFileEntry
.stats_i_oper_only
,
482 "STATS I output is only shown to operators",
487 &ConfigFileEntry
.stats_k_oper_only
,
488 "STATS K output is only shown to operators",
493 &ConfigFileEntry
.stats_o_oper_only
,
494 "STATS O output is only shown to operators",
499 &ConfigFileEntry
.stats_P_oper_only
,
500 "STATS P is only shown to operators",
505 &ConfigFileEntry
.stats_y_oper_only
,
506 "STATS Y is only shown to operators",
511 &ConfigFileEntry
.throttle_count
,
512 "Connection throttle threshold",
517 &ConfigFileEntry
.throttle_duration
,
518 "Connection throttle duration",
521 "tkline_expire_notices",
523 &ConfigFileEntry
.tkline_expire_notices
,
524 "Notices given to opers when tklines expire"
529 &ConfigFileEntry
.ts_max_delta
,
530 "Maximum permitted TS delta from another server"
535 &ConfigFileEntry
.ts_warn_delta
,
536 "Maximum permitted TS delta before displaying a warning"
541 &ConfigFileEntry
.warn_no_nline
,
542 "Display warning if connecting server lacks N-line"
545 "use_propagated_bans",
547 &ConfigFileEntry
.use_propagated_bans
,
548 "KLINE sets fully propagated bans"
551 "default_split_server_count",
553 &ConfigChannel
.default_split_server_count
,
554 "Startup value of SPLITNUM",
557 "default_split_user_count",
559 &ConfigChannel
.default_split_user_count
,
560 "Startup value of SPLITUSERS",
565 &ConfigChannel
.knock_delay
,
566 "Delay between a users KNOCK attempts"
569 "knock_delay_channel",
571 &ConfigChannel
.knock_delay_channel
,
572 "Delay between KNOCK attempts to a channel",
575 "kick_on_split_riding",
577 &ConfigChannel
.kick_on_split_riding
,
578 "Kick users riding splits to join +i or +k channels"
583 &ConfigChannel
.max_bans
,
584 "Total +b/e/I/q modes allowed in a channel",
589 &ConfigChannel
.max_bans_large
,
590 "Total +b/e/I/q modes allowed in a +L channel",
593 "max_chans_per_user",
595 &ConfigChannel
.max_chans_per_user
,
596 "Maximum number of channels a user can join",
599 "no_create_on_split",
601 &ConfigChannel
.no_create_on_split
,
602 "Disallow creation of channels when split",
607 &ConfigChannel
.no_join_on_split
,
608 "Disallow joining channels when split",
611 "only_ascii_channels",
613 &ConfigChannel
.only_ascii_channels
,
614 "Controls whether non-ASCII is disabled for JOIN"
619 &ConfigChannel
.cycle_host_change
,
620 "Controls if when a users' host changes, they cycle channels",
625 &ConfigChannel
.host_in_topic
,
626 "Defines whether a topicsetters host or just nick is shown on TOPIC",
629 "admin_on_channel_create",
631 &ConfigChannel
.admin_on_channel_create
,
632 "Give users +ao on channel create",
637 &ConfigChannel
.use_halfop
,
638 "Enable chanmode +h (halfop)",
643 &ConfigChannel
.use_admin
,
644 "Enable chanmode +a (admin)",
649 &ConfigChannel
.use_except
,
650 "Enable chanmode +e (ban exceptions)",
655 &ConfigChannel
.use_invex
,
656 "Enable chanmode +I (invite exceptions)",
661 &ConfigChannel
.use_forward
,
662 "Enable chanmode +f (channel forwarding)",
667 &ConfigChannel
.use_knock
,
671 "use_local_channels",
673 &ConfigChannel
.use_local_channels
,
674 "Enable local channels (&channels)"
679 &ConfigChannel
.resv_forcepart
,
680 "Force-part local users on channel RESV"
685 &ConfigServerHide
.disable_hidden
,
686 "Prevent servers from hiding themselves from a flattened /links",
691 &ConfigServerHide
.flatten_links
,
692 "Flatten /links list",
697 &ConfigServerHide
.hidden
,
698 "Hide this server from a flattened /links on remote servers",
703 &ConfigServerHide
.links_delay
,
706 /* --[ END OF TABLE ]---------------------------------------------- */
707 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
713 ** parv[1] = servername
716 m_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
718 static time_t last_used
= 0L;
720 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
722 /* safe enough to give this on a local connect only */
723 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
724 me
.name
, source_p
->name
, "INFO");
725 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
729 last_used
= rb_current_time();
731 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
736 send_info_text(source_p
);
737 send_birthdate_online_time(source_p
);
739 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
745 ** parv[1] = servername
748 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
750 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
753 send_info_text(source_p
);
757 send_conf_options(source_p
);
758 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
762 send_birthdate_online_time(source_p
);
764 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
773 * inputs - client pointer to send info text to
775 * side effects - info text is sent to client
778 send_info_text(struct Client
*source_p
)
780 const char **text
= infotext
;
784 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
787 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
791 * send_birthdate_online_time
793 * inputs - client pointer to send to
795 * side effects - birthdate and online time are sent
798 send_birthdate_online_time(struct Client
*source_p
)
800 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
801 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
802 get_id(&me
, source_p
), RPL_INFO
,
803 get_id(source_p
, source_p
), creation
, generation
);
805 sendto_one(source_p
, ":%s %d %s :On-line since %s",
806 get_id(&me
, source_p
), RPL_INFO
,
807 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
813 * inputs - client pointer to send to
815 * side effects - send config options to client
818 send_conf_options(struct Client
*source_p
)
824 * Now send them a list of all our configuration options
825 * (mostly from config.h)
827 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
829 if(infoptr
->intvalue
)
831 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
832 get_id(&me
, source_p
), RPL_INFO
,
833 get_id(source_p
, source_p
),
834 infoptr
->name
, infoptr
->intvalue
,
839 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
840 get_id(&me
, source_p
), RPL_INFO
,
841 get_id(source_p
, source_p
),
842 infoptr
->name
, infoptr
->strvalue
,
848 * Parse the info_table[] and do the magic.
850 for (i
= 0; info_table
[i
].name
; i
++)
852 switch (info_table
[i
].output_type
)
855 * For "char *" references
859 char *option
= *((char **) info_table
[i
].option
);
861 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
862 get_id(&me
, source_p
), RPL_INFO
,
863 get_id(source_p
, source_p
),
865 option
? option
: "NONE",
866 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
871 * For "char foo[]" references
873 case OUTPUT_STRING_PTR
:
875 char *option
= (char *) info_table
[i
].option
;
877 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
878 get_id(&me
, source_p
), RPL_INFO
,
879 get_id(source_p
, source_p
),
881 EmptyString(option
) ? "NONE" : option
,
882 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
887 * Output info_table[i].option as a decimal value.
891 int option
= *((int *) info_table
[i
].option
);
893 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
894 get_id(&me
, source_p
), RPL_INFO
,
895 get_id(source_p
, source_p
),
898 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
904 * Output info_table[i].option as "ON" or "OFF"
908 int option
= *((int *) info_table
[i
].option
);
910 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
911 get_id(&me
, source_p
), RPL_INFO
,
912 get_id(source_p
, source_p
),
914 option
? "ON" : "OFF",
915 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
920 * Output info_table[i].option as "YES" or "NO"
922 case OUTPUT_BOOLEAN_YN
:
924 int option
= *((int *) info_table
[i
].option
);
926 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
927 get_id(&me
, source_p
), RPL_INFO
,
928 get_id(source_p
, source_p
),
930 option
? "YES" : "NO",
931 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
936 case OUTPUT_BOOLEAN2
:
938 int option
= *((int *) info_table
[i
].option
);
940 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
941 me
.name
, RPL_INFO
, source_p
->name
,
943 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
944 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
945 } /* switch (info_table[i].output_type) */
950 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
951 ** in order for it to show up properly to opers who issue INFO
954 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
959 * input - pointer to client
961 * side effects - hook doing_info is called
964 info_spy(struct Client
*source_p
)
968 hd
.client
= source_p
;
969 hd
.arg1
= hd
.arg2
= NULL
;
971 call_hook(doing_info_hook
, &hd
);