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 DECLARE_MODULE_AV1(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, "$Revision: 3396 $");
66 * jdc -- Structure for our configuration value table
70 const char *name
; /* Displayed variable name */
71 unsigned int output_type
; /* See below #defines */
72 void *option
; /* Pointer reference to the value */
73 const char *desc
; /* ASCII description of the variable */
75 /* Types for output_type in InfoStruct */
76 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
77 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
78 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
79 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
80 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
81 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
84 static struct InfoStruct info_table
[] = {
85 /* --[ START OF TABLE ]-------------------------------------------- */
87 "opers_see_all_users",
90 "Farconnect notices available or operspy accountability limited"
96 "Max number connections"
101 &ConfigFileEntry
.anti_nick_flood
,
102 "NICK flood protection"
105 "anti_spam_exit_message_time",
107 &ConfigFileEntry
.anti_spam_exit_message_time
,
108 "Duration a client must be connected for to have an exit message"
113 &ConfigFileEntry
.caller_id_wait
,
114 "Minimum delay between notifying UMODE +g users of messages"
119 &ConfigFileEntry
.client_exit
,
120 "Prepend 'Quit:' to user QUIT messages"
123 "client_flood_max_lines",
125 &ConfigFileEntry
.client_flood_max_lines
,
126 "Number of lines before a client Excess Flood's",
129 "client_flood_burst_rate",
131 &ConfigFileEntry
.client_flood_burst_rate
,
132 "Maximum lines per second during flood grace period",
135 "client_flood_burst_max",
137 &ConfigFileEntry
.client_flood_burst_max
,
138 "Number of lines to process at once before delaying",
141 "client_flood_message_num",
143 &ConfigFileEntry
.client_flood_message_num
,
144 "Number of messages to allow per client_flood_message_time outside of burst",
147 "client_flood_message_time",
149 &ConfigFileEntry
.client_flood_message_time
,
150 "Time to allow per client_flood_message_num outside of burst",
155 &ConfigFileEntry
.connect_timeout
,
156 "Connect timeout for connections to servers"
159 "default_ident_timeout",
161 &ConfigFileEntry
.default_ident_timeout
,
162 "Amount of time the server waits for ident responses from clients",
165 "default_floodcount",
167 &ConfigFileEntry
.default_floodcount
,
168 "Startup value of FLOODCOUNT",
171 "default_adminstring",
173 &ConfigFileEntry
.default_adminstring
,
174 "Default adminstring at startup.",
177 "default_operstring",
179 &ConfigFileEntry
.default_operstring
,
180 "Default operstring at startup.",
185 &ConfigFileEntry
.servicestring
,
186 "String shown in whois for opered services.",
191 &ConfigFileEntry
.disable_auth
,
192 "Controls whether auth checking is disabled or not"
195 "disable_fake_channels",
197 &ConfigFileEntry
.disable_fake_channels
,
198 "Controls whether bold etc are disabled for JOIN"
203 &ConfigFileEntry
.dots_in_ident
,
204 "Number of permissable dots in an ident"
207 "failed_oper_notice",
209 &ConfigFileEntry
.failed_oper_notice
,
210 "Inform opers if someone /oper's with the wrong password"
215 &ConfigFileEntry
.fname_userlog
,
221 &ConfigFileEntry
.fname_fuserlog
,
222 "Failed user log file"
228 &ConfigFileEntry
.fname_operlog
,
234 &ConfigFileEntry
.fname_foperlog
,
235 "Failed operator log file"
240 &ConfigFileEntry
.fname_serverlog
,
241 "Server connect/disconnect log file"
246 &ConfigFileEntry
.fname_killlog
,
252 &ConfigFileEntry
.fname_klinelog
,
258 &ConfigFileEntry
.fname_operspylog
,
264 &ConfigFileEntry
.fname_ioerrorlog
,
270 &ConfigFileEntry
.global_snotices
,
271 "Send out certain server notices globally"
274 "hide_error_messages",
276 &ConfigFileEntry
.hide_error_messages
,
277 "Hide ERROR messages coming from servers"
282 &ConfigFileEntry
.hide_spoof_ips
,
283 "Hide IPs of spoofed users"
294 &ConfigFileEntry
.kline_delay
,
295 "Duration of time to delay kline checking"
300 &ConfigFileEntry
.kline_reason
,
301 "K-lined clients sign off with this reason"
306 &ConfigFileEntry
.dline_with_reason
,
307 "Display D-line reason to client on disconnect"
312 &ConfigFileEntry
.kline_with_reason
,
313 "Display K-line reason to client on disconnect"
318 &ConfigFileEntry
.max_accept
,
319 "Maximum nicknames on accept list",
324 &ConfigFileEntry
.max_nick_changes
,
325 "NICK change threshhold setting"
330 &ConfigFileEntry
.max_nick_time
,
331 "NICK flood protection time interval"
336 &ConfigFileEntry
.max_targets
,
337 "The maximum number of PRIVMSG/NOTICE targets"
342 &ConfigFileEntry
.min_nonwildcard
,
343 "Minimum non-wildcard chars in K lines",
346 "min_nonwildcard_simple",
348 &ConfigFileEntry
.min_nonwildcard_simple
,
349 "Minimum non-wildcard chars in xlines/resvs",
354 &ServerInfo
.network_name
,
360 &ConfigFileEntry
.nick_delay
,
361 "Delay nicks are locked for on split",
366 &ConfigFileEntry
.no_oper_flood
,
367 "Disable flood control for operators",
370 "non_redundant_klines",
372 &ConfigFileEntry
.non_redundant_klines
,
373 "Check for and disallow redundant K-lines"
376 "operspy_admin_only",
378 &ConfigFileEntry
.operspy_admin_only
,
379 "Send +Z operspy notices to admins only"
382 "operspy_dont_care_user_info",
384 &ConfigFileEntry
.operspy_dont_care_user_info
,
385 "Remove accountability and some '!' requirement from non-channel operspy"
390 &ConfigFileEntry
.pace_wait
,
391 "Minimum delay between uses of certain commands"
396 &ConfigFileEntry
.pace_wait_simple
,
397 "Minimum delay between less intensive commands"
402 &ConfigFileEntry
.ping_cookie
,
403 "Require ping cookies to connect",
406 "reject_after_count",
408 &ConfigFileEntry
.reject_after_count
,
409 "Client rejection threshold setting",
414 &ConfigFileEntry
.reject_ban_time
,
415 "Client rejection time interval",
420 &ConfigFileEntry
.reject_duration
,
421 "Client rejection cache duration",
426 &ConfigFileEntry
.short_motd
,
427 "Do not show MOTD; only tell clients they should read it"
432 &ConfigFileEntry
.stats_e_disabled
,
433 "STATS e output is disabled",
438 &ConfigFileEntry
.stats_c_oper_only
,
439 "STATS C output is only shown to operators",
444 &ConfigFileEntry
.stats_h_oper_only
,
445 "STATS H output is only shown to operators",
450 &ConfigFileEntry
.stats_i_oper_only
,
451 "STATS I output is only shown to operators",
456 &ConfigFileEntry
.stats_k_oper_only
,
457 "STATS K output is only shown to operators",
462 &ConfigFileEntry
.stats_o_oper_only
,
463 "STATS O output is only shown to operators",
468 &ConfigFileEntry
.stats_P_oper_only
,
469 "STATS P is only shown to operators",
474 &ConfigFileEntry
.stats_y_oper_only
,
475 "STATS Y is only shown to operators",
480 &ConfigFileEntry
.throttle_count
,
481 "Connection throttle threshold",
486 &ConfigFileEntry
.throttle_duration
,
487 "Connection throttle duration",
490 "tkline_expire_notices",
492 &ConfigFileEntry
.tkline_expire_notices
,
493 "Notices given to opers when tklines expire"
498 &ConfigFileEntry
.ts_max_delta
,
499 "Maximum permitted TS delta from another server"
504 &ConfigFileEntry
.ts_warn_delta
,
505 "Maximum permitted TS delta before displaying a warning"
510 &ConfigFileEntry
.warn_no_nline
,
511 "Display warning if connecting server lacks connect block"
514 "use_propagated_bans",
516 &ConfigFileEntry
.use_propagated_bans
,
517 "KLINE sets fully propagated bans"
520 "max_ratelimit_tokens",
522 &ConfigFileEntry
.max_ratelimit_tokens
,
523 "The maximum number of tokens that can be accumulated for executing rate-limited commands",
528 &ConfigFileEntry
.away_interval
,
529 "The minimum time between aways",
532 "default_split_server_count",
534 &ConfigChannel
.default_split_server_count
,
535 "Startup value of SPLITNUM",
538 "default_split_user_count",
540 &ConfigChannel
.default_split_user_count
,
541 "Startup value of SPLITUSERS",
546 &ConfigChannel
.knock_delay
,
547 "Delay between a users KNOCK attempts"
550 "knock_delay_channel",
552 &ConfigChannel
.knock_delay_channel
,
553 "Delay between KNOCK attempts to a channel",
556 "kick_on_split_riding",
558 &ConfigChannel
.kick_on_split_riding
,
559 "Kick users riding splits to join +i or +k channels"
562 "disable_local_channels",
564 &ConfigChannel
.disable_local_channels
,
565 "Disable local channels (&channels)"
570 &ConfigChannel
.max_bans
,
571 "Total +b/e/I/q modes allowed in a channel",
576 &ConfigChannel
.max_bans_large
,
577 "Total +b/e/I/q modes allowed in a +L channel",
580 "max_chans_per_user",
582 &ConfigChannel
.max_chans_per_user
,
583 "Maximum number of channels a user can join",
586 "max_chans_per_user_large",
588 &ConfigChannel
.max_chans_per_user_large
,
589 "Maximum extended number of channels a user can join",
592 "no_create_on_split",
594 &ConfigChannel
.no_create_on_split
,
595 "Disallow creation of channels when split",
600 &ConfigChannel
.no_join_on_split
,
601 "Disallow joining channels when split",
604 "only_ascii_channels",
606 &ConfigChannel
.only_ascii_channels
,
607 "Controls whether non-ASCII is disabled for JOIN"
612 &ConfigChannel
.use_except
,
613 "Enable chanmode +e (ban exceptions)",
618 &ConfigChannel
.use_invex
,
619 "Enable chanmode +I (invite exceptions)",
624 &ConfigChannel
.use_forward
,
625 "Enable chanmode +f (channel forwarding)",
630 &ConfigChannel
.use_knock
,
636 &ConfigChannel
.resv_forcepart
,
637 "Force-part local users on channel RESV"
642 &ConfigServerHide
.disable_hidden
,
643 "Prevent servers from hiding themselves from a flattened /links",
648 &ConfigServerHide
.flatten_links
,
649 "Flatten /links list",
654 &ConfigServerHide
.hidden
,
655 "Hide this server from a flattened /links on remote servers",
660 &ConfigServerHide
.links_delay
,
663 /* --[ END OF TABLE ]---------------------------------------------- */
664 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
670 ** parv[1] = servername
673 m_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
675 static time_t last_used
= 0L;
677 if((last_used
+ ConfigFileEntry
.pace_wait
) > rb_current_time())
679 /* safe enough to give this on a local connect only */
680 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
681 me
.name
, source_p
->name
, "INFO");
682 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
686 last_used
= rb_current_time();
688 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
693 send_info_text(source_p
);
694 send_birthdate_online_time(source_p
);
696 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
702 ** parv[1] = servername
705 mo_info(struct MsgBuf
*msgbuf_p
, struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
707 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
710 send_info_text(source_p
);
714 send_conf_options(source_p
);
715 sendto_one_numeric(source_p
, RPL_INFO
, ":%s",
719 send_birthdate_online_time(source_p
);
721 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
730 * inputs - client pointer to send info text to
732 * side effects - info text is sent to client
735 send_info_text(struct Client
*source_p
)
737 const char **text
= infotext
;
741 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
744 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
748 * send_birthdate_online_time
750 * inputs - client pointer to send to
752 * side effects - birthdate and online time are sent
755 send_birthdate_online_time(struct Client
*source_p
)
757 char tbuf
[26]; /* this needs to be 26 - see ctime_r manpage */
758 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
759 get_id(&me
, source_p
), RPL_INFO
,
760 get_id(source_p
, source_p
), creation
, generation
);
762 sendto_one(source_p
, ":%s %d %s :On-line since %s",
763 get_id(&me
, source_p
), RPL_INFO
,
764 get_id(source_p
, source_p
), rb_ctime(startup_time
, tbuf
, sizeof(tbuf
)));
770 * inputs - client pointer to send to
772 * side effects - send config options to client
775 send_conf_options(struct Client
*source_p
)
781 * Now send them a list of all our configuration options
782 * (mostly from config.h)
784 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
786 if(infoptr
->intvalue
)
788 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
789 get_id(&me
, source_p
), RPL_INFO
,
790 get_id(source_p
, source_p
),
791 infoptr
->name
, infoptr
->intvalue
,
796 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
797 get_id(&me
, source_p
), RPL_INFO
,
798 get_id(source_p
, source_p
),
799 infoptr
->name
, infoptr
->strvalue
,
805 * Parse the info_table[] and do the magic.
807 for (i
= 0; info_table
[i
].name
; i
++)
809 switch (info_table
[i
].output_type
)
812 * For "char *" references
816 char *option
= *((char **) info_table
[i
].option
);
818 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
819 get_id(&me
, source_p
), RPL_INFO
,
820 get_id(source_p
, source_p
),
822 option
? option
: "NONE",
823 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
828 * For "char foo[]" references
830 case OUTPUT_STRING_PTR
:
832 char *option
= (char *) info_table
[i
].option
;
834 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
835 get_id(&me
, source_p
), RPL_INFO
,
836 get_id(source_p
, source_p
),
838 EmptyString(option
) ? "NONE" : option
,
839 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
844 * Output info_table[i].option as a decimal value.
848 int option
= *((int *) info_table
[i
].option
);
850 sendto_one(source_p
, ":%s %d %s :%-30s %-16d [%s]",
851 get_id(&me
, source_p
), RPL_INFO
,
852 get_id(source_p
, source_p
),
855 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
861 * Output info_table[i].option as "ON" or "OFF"
865 int option
= *((int *) info_table
[i
].option
);
867 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
868 get_id(&me
, source_p
), RPL_INFO
,
869 get_id(source_p
, source_p
),
871 option
? "ON" : "OFF",
872 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
877 * Output info_table[i].option as "YES" or "NO"
879 case OUTPUT_BOOLEAN_YN
:
881 int option
= *((int *) info_table
[i
].option
);
883 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
884 get_id(&me
, source_p
), RPL_INFO
,
885 get_id(source_p
, source_p
),
887 option
? "YES" : "NO",
888 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
893 case OUTPUT_BOOLEAN2
:
895 int option
= *((int *) info_table
[i
].option
);
897 sendto_one(source_p
, ":%s %d %s :%-30s %-16s [%s]",
898 me
.name
, RPL_INFO
, source_p
->name
,
900 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
901 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
902 } /* switch (info_table[i].output_type) */
907 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
908 ** in order for it to show up properly to opers who issue INFO
911 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
916 * input - pointer to client
918 * side effects - hook doing_info is called
921 info_spy(struct Client
*source_p
)
925 hd
.client
= source_p
;
926 hd
.arg1
= hd
.arg2
= NULL
;
928 call_hook(doing_info_hook
, &hd
);