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
42 static void send_conf_options(struct Client
*source_p
);
43 static void send_birthdate_online_time(struct Client
*source_p
);
44 static void send_info_text(struct Client
*source_p
);
45 static void info_spy(struct Client
*);
47 static int m_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
48 static int mo_info(struct MsgBuf
*, struct Client
*, struct Client
*, int, const char **);
50 struct Message info_msgtab
= {
52 {mg_unreg
, {m_info
, 0}, {mo_info
, 0}, mg_ignore
, mg_ignore
, {mo_info
, 0}}
57 mapi_clist_av1 info_clist
[] = { &info_msgtab
, NULL
};
58 mapi_hlist_av1 info_hlist
[] = {
59 { "doing_info", &doing_info_hook
},
63 static const char info_desc
[] =
64 "Provides the INFO command for retrieving server copyright, credits, and other info";
66 DECLARE_MODULE_AV2(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, NULL
, NULL
, info_desc
);
69 * jdc -- Structure for our configuration value table
73 const char *name
; /* Displayed variable name */
74 unsigned int output_type
; /* See below #defines */
75 void *option
; /* Pointer reference to the value */
76 const char *desc
; /* ASCII description of the variable */
78 /* Types for output_type in InfoStruct */
79 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
80 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
81 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
82 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
83 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
84 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
87 static struct InfoStruct info_table
[] = {
88 /* --[ START OF TABLE ]-------------------------------------------- */
90 "opers_see_all_users",
93 "Farconnect notices available or operspy accountability limited"
99 "Max number connections"
104 &ConfigFileEntry
.anti_nick_flood
,
105 "NICK flood protection"
108 "anti_spam_exit_message_time",
110 &ConfigFileEntry
.anti_spam_exit_message_time
,
111 "Duration a client must be connected for to have an exit message"
116 &ConfigFileEntry
.caller_id_wait
,
117 "Minimum delay between notifying UMODE +g users of messages"
122 &ConfigFileEntry
.client_exit
,
123 "Prepend 'Quit:' to user QUIT messages"
126 "client_flood_max_lines",
128 &ConfigFileEntry
.client_flood_max_lines
,
129 "Number of lines before a client Excess Flood's",
132 "client_flood_burst_rate",
134 &ConfigFileEntry
.client_flood_burst_rate
,
135 "Maximum lines per second during flood grace period",
138 "client_flood_burst_max",
140 &ConfigFileEntry
.client_flood_burst_max
,
141 "Number of lines to process at once before delaying",
144 "client_flood_message_num",
146 &ConfigFileEntry
.client_flood_message_num
,
147 "Number of messages to allow per client_flood_message_time outside of burst",
150 "client_flood_message_time",
152 &ConfigFileEntry
.client_flood_message_time
,
153 "Time to allow per client_flood_message_num outside of burst",
158 &ConfigFileEntry
.connect_timeout
,
159 "Connect timeout for connections to servers"
162 "default_ident_timeout",
164 &ConfigFileEntry
.default_ident_timeout
,
165 "Amount of time the server waits for ident responses from clients",
168 "default_floodcount",
170 &ConfigFileEntry
.default_floodcount
,
171 "Startup value of FLOODCOUNT",
174 "default_adminstring",
176 &ConfigFileEntry
.default_adminstring
,
177 "Default adminstring at startup.",
180 "default_operstring",
182 &ConfigFileEntry
.default_operstring
,
183 "Default operstring at startup.",
188 &ConfigFileEntry
.servicestring
,
189 "String shown in whois for opered services.",
194 &ConfigFileEntry
.disable_auth
,
195 "Controls whether auth checking is disabled or not"
198 "disable_fake_channels",
200 &ConfigFileEntry
.disable_fake_channels
,
201 "Controls whether bold etc are disabled for JOIN"
206 &ConfigFileEntry
.dots_in_ident
,
207 "Number of permissable dots in an ident"
210 "failed_oper_notice",
212 &ConfigFileEntry
.failed_oper_notice
,
213 "Inform opers if someone /oper's with the wrong password"
218 &ConfigFileEntry
.fname_userlog
,
224 &ConfigFileEntry
.fname_fuserlog
,
225 "Failed user log file"
231 &ConfigFileEntry
.fname_operlog
,
237 &ConfigFileEntry
.fname_foperlog
,
238 "Failed operator log file"
243 &ConfigFileEntry
.fname_serverlog
,
244 "Server connect/disconnect log file"
249 &ConfigFileEntry
.fname_killlog
,
255 &ConfigFileEntry
.fname_klinelog
,
261 &ConfigFileEntry
.fname_operspylog
,
267 &ConfigFileEntry
.fname_ioerrorlog
,
273 &ConfigFileEntry
.global_snotices
,
274 "Send out certain server notices globally"
277 "hide_error_messages",
279 &ConfigFileEntry
.hide_error_messages
,
280 "Hide ERROR messages coming from servers"
285 &ConfigFileEntry
.hide_spoof_ips
,
286 "Hide IPs of spoofed users"
297 &ConfigFileEntry
.kline_delay
,
298 "Duration of time to delay kline checking"
303 &ConfigFileEntry
.kline_reason
,
304 "K-lined clients sign off with this reason"
309 &ConfigFileEntry
.dline_with_reason
,
310 "Display D-line reason to client on disconnect"
315 &ConfigFileEntry
.kline_with_reason
,
316 "Display K-line reason to client on disconnect"
321 &ConfigFileEntry
.max_accept
,
322 "Maximum nicknames on accept list",
327 &ConfigFileEntry
.max_nick_changes
,
328 "NICK change threshhold setting"
333 &ConfigFileEntry
.max_nick_time
,
334 "NICK flood protection time interval"
339 &ConfigFileEntry
.max_targets
,
340 "The maximum number of PRIVMSG/NOTICE targets"
345 &ConfigFileEntry
.min_nonwildcard
,
346 "Minimum non-wildcard chars in K lines",
349 "min_nonwildcard_simple",
351 &ConfigFileEntry
.min_nonwildcard_simple
,
352 "Minimum non-wildcard chars in xlines/resvs",
357 &ServerInfo
.network_name
,
363 &ConfigFileEntry
.nick_delay
,
364 "Delay nicks are locked for on split",
369 &ConfigFileEntry
.no_oper_flood
,
370 "Disable flood control for operators",
373 "non_redundant_klines",
375 &ConfigFileEntry
.non_redundant_klines
,
376 "Check for and disallow redundant K-lines"
379 "operspy_admin_only",
381 &ConfigFileEntry
.operspy_admin_only
,
382 "Send +Z operspy notices to admins only"
385 "operspy_dont_care_user_info",
387 &ConfigFileEntry
.operspy_dont_care_user_info
,
388 "Remove accountability and some '!' requirement from non-channel operspy"
393 &ConfigFileEntry
.pace_wait
,
394 "Minimum delay between uses of certain commands"
399 &ConfigFileEntry
.pace_wait_simple
,
400 "Minimum delay between less intensive commands"
405 &ConfigFileEntry
.ping_cookie
,
406 "Require ping cookies to connect",
409 "reject_after_count",
411 &ConfigFileEntry
.reject_after_count
,
412 "Client rejection threshold setting",
417 &ConfigFileEntry
.reject_ban_time
,
418 "Client rejection time interval",
423 &ConfigFileEntry
.reject_duration
,
424 "Client rejection cache duration",
429 &ConfigFileEntry
.short_motd
,
430 "Do not show MOTD; only tell clients they should read it"
435 &ConfigFileEntry
.stats_e_disabled
,
436 "STATS e output is disabled",
441 &ConfigFileEntry
.stats_c_oper_only
,
442 "STATS C output is only shown to operators",
447 &ConfigFileEntry
.stats_h_oper_only
,
448 "STATS H output is only shown to operators",
453 &ConfigFileEntry
.stats_i_oper_only
,
454 "STATS I output is only shown to operators",
459 &ConfigFileEntry
.stats_k_oper_only
,
460 "STATS K output is only shown to operators",
465 &ConfigFileEntry
.stats_o_oper_only
,
466 "STATS O output is only shown to operators",
471 &ConfigFileEntry
.stats_P_oper_only
,
472 "STATS P is only shown to operators",
477 &ConfigFileEntry
.stats_y_oper_only
,
478 "STATS Y is only shown to operators",
483 &ConfigFileEntry
.throttle_count
,
484 "Connection throttle threshold",
489 &ConfigFileEntry
.throttle_duration
,
490 "Connection throttle duration",
493 "tkline_expire_notices",
495 &ConfigFileEntry
.tkline_expire_notices
,
496 "Notices given to opers when tklines expire"
501 &ConfigFileEntry
.ts_max_delta
,
502 "Maximum permitted TS delta from another server"
507 &ConfigFileEntry
.ts_warn_delta
,
508 "Maximum permitted TS delta before displaying a warning"
513 &ConfigFileEntry
.warn_no_nline
,
514 "Display warning if connecting server lacks connect block"
517 "use_propagated_bans",
519 &ConfigFileEntry
.use_propagated_bans
,
520 "KLINE sets fully propagated bans"
523 "max_ratelimit_tokens",
525 &ConfigFileEntry
.max_ratelimit_tokens
,
526 "The maximum number of tokens that can be accumulated for executing rate-limited commands",
531 &ConfigFileEntry
.away_interval
,
532 "The minimum time between aways",
535 "default_split_server_count",
537 &ConfigChannel
.default_split_server_count
,
538 "Startup value of SPLITNUM",
541 "default_split_user_count",
543 &ConfigChannel
.default_split_user_count
,
544 "Startup value of SPLITUSERS",
549 &ConfigChannel
.knock_delay
,
550 "Delay between a users KNOCK attempts"
553 "knock_delay_channel",
555 &ConfigChannel
.knock_delay_channel
,
556 "Delay between KNOCK attempts to a channel",
559 "kick_on_split_riding",
561 &ConfigChannel
.kick_on_split_riding
,
562 "Kick users riding splits to join +i or +k channels"
565 "disable_local_channels",
567 &ConfigChannel
.disable_local_channels
,
568 "Disable local channels (&channels)"
573 &ConfigChannel
.max_bans
,
574 "Total +b/e/I/q modes allowed in a channel",
579 &ConfigChannel
.max_bans_large
,
580 "Total +b/e/I/q modes allowed in a +L channel",
583 "max_chans_per_user",
585 &ConfigChannel
.max_chans_per_user
,
586 "Maximum number of channels a user can join",
589 "max_chans_per_user_large",
591 &ConfigChannel
.max_chans_per_user_large
,
592 "Maximum extended number of channels a user can join",
595 "no_create_on_split",
597 &ConfigChannel
.no_create_on_split
,
598 "Disallow creation of channels when split",
603 &ConfigChannel
.no_join_on_split
,
604 "Disallow joining channels when split",
607 "only_ascii_channels",
609 &ConfigChannel
.only_ascii_channels
,
610 "Controls whether non-ASCII is disabled for JOIN"
615 &ConfigChannel
.use_except
,
616 "Enable chanmode +e (ban exceptions)",
621 &ConfigChannel
.use_invex
,
622 "Enable chanmode +I (invite exceptions)",
627 &ConfigChannel
.use_forward
,
628 "Enable chanmode +f (channel forwarding)",
633 &ConfigChannel
.use_knock
,
639 &ConfigChannel
.resv_forcepart
,
640 "Force-part local users on channel RESV"
645 &ConfigServerHide
.disable_hidden
,
646 "Prevent servers from hiding themselves from a flattened /links",
651 &ConfigServerHide
.flatten_links
,
652 "Flatten /links list",
657 &ConfigServerHide
.hidden
,
658 "Hide this server from a flattened /links on remote servers",
663 &ConfigServerHide
.links_delay
,
666 /* --[ END OF TABLE ]---------------------------------------------- */
667 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
673 ** parv[1] = servername
676 m_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
678 static time_t last_used
= 0L;
680 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
682 /* safe enough to give this on a local connect only */
683 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
684 me
.name
, source_p
->name
, "INFO");
685 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
689 last_used
= rb_current_time();
691 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
696 send_info_text(source_p
);
697 send_birthdate_online_time(source_p
);
699 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
705 ** parv[1] = servername
708 mo_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
710 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
713 send_info_text(source_p
);
717 send_conf_options(source_p
);
718 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
722 send_birthdate_online_time(source_p
);
724 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
733 * inputs - client pointer to send info text to
735 * side effects - info text is sent to client
738 send_info_text(struct Client
*source_p
)
740 const char **text
= infotext
;
744 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
747 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
751 * send_birthdate_online_time
753 * inputs - client pointer to send to
755 * side effects - birthdate and online time are sent
758 send_birthdate_online_time(struct Client
*source_p
)
760 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
761 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
762 get_id(&me
, source_p
), RPL_INFO
,
763 get_id(source_p
, source_p
), creation
, generation
);
765 sendto_one(source_p
, ":%s %d %s :On-line since %s",
766 get_id(&me
, source_p
), RPL_INFO
,
767 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
773 * inputs - client pointer to send to
775 * side effects - send config options to client
778 send_conf_options(struct Client
*source_p
)
784 * Now send them a list of all our configuration options
785 * (mostly from config.h)
787 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
789 if(infoptr
->intvalue
)
791 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
792 get_id(&me
, source_p
), RPL_INFO
,
793 get_id(source_p
, source_p
),
794 infoptr
->name
, infoptr
->intvalue
,
799 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
800 get_id(&me
, source_p
), RPL_INFO
,
801 get_id(source_p
, source_p
),
802 infoptr
->name
, infoptr
->strvalue
,
808 * Parse the info_table[] and do the magic.
810 for (i
= 0; info_table
[i
].name
; i
++)
812 switch (info_table
[i
].output_type
)
815 * For "char *" references
819 char *option
= *((char **) info_table
[i
].option
);
821 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
822 get_id(&me
, source_p
), RPL_INFO
,
823 get_id(source_p
, source_p
),
825 option
? option
: "NONE",
826 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
831 * For "char foo[]" references
833 case OUTPUT_STRING_PTR
:
835 char *option
= (char *) info_table
[i
].option
;
837 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
838 get_id(&me
, source_p
), RPL_INFO
,
839 get_id(source_p
, source_p
),
841 EmptyString(option
) ? "NONE" : option
,
842 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
847 * Output info_table[i].option as a decimal value.
851 int option
= *((int *) info_table
[i
].option
);
853 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
854 get_id(&me
, source_p
), RPL_INFO
,
855 get_id(source_p
, source_p
),
858 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
864 * Output info_table[i].option as "ON" or "OFF"
868 int option
= *((int *) info_table
[i
].option
);
870 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
871 get_id(&me
, source_p
), RPL_INFO
,
872 get_id(source_p
, source_p
),
874 option
? "ON" : "OFF",
875 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
880 * Output info_table[i].option as "YES" or "NO"
882 case OUTPUT_BOOLEAN_YN
:
884 int option
= *((int *) info_table
[i
].option
);
886 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
887 get_id(&me
, source_p
), RPL_INFO
,
888 get_id(source_p
, source_p
),
890 option
? "YES" : "NO",
891 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
896 case OUTPUT_BOOLEAN2
:
898 int option
= *((int *) info_table
[i
].option
);
900 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
901 me
.name
, RPL_INFO
, source_p
->name
,
903 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
904 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
905 } /* switch (info_table[i].output_type) */
910 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
911 ** in order for it to show up properly to opers who issue INFO
914 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
919 * input - pointer to client
921 * side effects - hook doing_info is called
924 info_spy(struct Client
*source_p
)
928 hd
.client
= source_p
;
929 hd
.arg1
= hd
.arg2
= NULL
;
931 call_hook(doing_info_hook
, &hd
);