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 3257 2007-03-13 16:09:28Z jilles $
33 #include "irc_string.h"
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 int m_info(struct Client
*, struct Client
*, int, const char **);
51 static int mo_info(struct Client
*, struct Client
*, int, const char **);
53 struct Message info_msgtab
= {
54 "INFO", 0, 0, 0, MFLG_SLOW
,
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_AV1(info
, NULL
, NULL
, info_clist
, info_hlist
, NULL
, "$Revision: 3257 $");
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"
98 &ConfigFileEntry
.anti_nick_flood
,
99 "NICK flood protection"
102 "anti_spam_exit_message_time",
104 &ConfigFileEntry
.anti_spam_exit_message_time
,
105 "Duration a client must be connected for to have an exit message"
110 &ConfigFileEntry
.caller_id_wait
,
111 "Minimum delay between notifying UMODE +g users of messages"
116 &ConfigFileEntry
.client_exit
,
117 "Prepend 'Client Exit:' to user QUIT messages"
122 &ConfigFileEntry
.client_flood
,
123 "Number of lines before a client Excess Flood's",
128 &ConfigFileEntry
.connect_timeout
,
129 "Connect timeout for connections to servers"
132 "default_floodcount",
134 &ConfigFileEntry
.default_floodcount
,
135 "Startup value of FLOODCOUNT",
138 "default_adminstring",
140 &ConfigFileEntry
.default_adminstring
,
141 "Default adminstring at startup.",
144 "default_operstring",
146 &ConfigFileEntry
.default_operstring
,
147 "Default operstring at startup.",
152 &ConfigFileEntry
.servicestring
,
153 "String shown in whois for opered services.",
158 &ConfigFileEntry
.disable_auth
,
159 "Controls whether auth checking is disabled or not"
162 "disable_fake_channels",
164 &ConfigFileEntry
.disable_fake_channels
,
165 "Controls whether bold etc are disabled for JOIN"
170 &ConfigFileEntry
.dot_in_ip6_addr
,
171 "Suffix a . to ip6 addresses",
176 &ConfigFileEntry
.dots_in_ident
,
177 "Number of permissable dots in an ident"
180 "failed_oper_notice",
182 &ConfigFileEntry
.failed_oper_notice
,
183 "Inform opers if someone /oper's with the wrong password"
188 &ConfigFileEntry
.fname_userlog
,
194 &ConfigFileEntry
.fname_fuserlog
,
195 "Failed user log file"
201 &ConfigFileEntry
.fname_operlog
,
207 &ConfigFileEntry
.fname_foperlog
,
208 "Failed operator log file"
213 &ConfigFileEntry
.fname_serverlog
,
214 "Server connect/disconnect log file"
219 &ConfigFileEntry
.fname_klinelog
,
225 &ConfigFileEntry
.fname_glinelog
,
231 &ConfigFileEntry
.fname_operspylog
,
237 &ConfigFileEntry
.fname_ioerrorlog
,
243 &ConfigFileEntry
.glines
,
244 "G-line (network-wide K-line) support"
249 &ConfigFileEntry
.gline_time
,
250 "Expiry time for G-lines"
255 &ConfigFileEntry
.gline_min_cidr
,
256 "Minimum CIDR bitlen for ipv4 glines"
261 &ConfigFileEntry
.gline_min_cidr6
,
262 "Minimum CIDR bitlen for ipv6 glines"
267 &ConfigFileEntry
.global_snotices
,
268 "Send out certain server notices globally"
271 "hide_error_messages",
273 &ConfigFileEntry
.hide_error_messages
,
274 "Hide ERROR messages coming from servers"
279 &ConfigFileEntry
.hide_spoof_ips
,
280 "Hide IPs of spoofed users"
291 &ConfigFileEntry
.idletime
,
292 "Number of minutes before a client is considered idle"
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/G lines",
349 "min_nonwildcard_simple",
351 &ConfigFileEntry
.min_nonwildcard_simple
,
352 "Minimum non-wildcard chars in xlines/resvs",
357 &ServerInfo
.network_name
,
363 &ServerInfo
.network_desc
,
364 "Network description"
369 &ConfigFileEntry
.nick_delay
,
370 "Delay nicks are locked for on split",
375 &ConfigFileEntry
.no_oper_flood
,
376 "Disable flood control for operators",
379 "non_redundant_klines",
381 &ConfigFileEntry
.non_redundant_klines
,
382 "Check for and disallow redundant K-lines"
385 "operspy_admin_only",
387 &ConfigFileEntry
.operspy_admin_only
,
388 "Send +Z operspy notices to admins only"
391 "operspy_dont_care_user_info",
393 &ConfigFileEntry
.operspy_dont_care_user_info
,
394 "Remove accountability and some '!' requirement from non-channel operspy"
399 &ConfigFileEntry
.pace_wait
,
400 "Minimum delay between uses of certain commands"
405 &ConfigFileEntry
.pace_wait_simple
,
406 "Minimum delay between less intensive commands"
411 &ConfigFileEntry
.ping_cookie
,
412 "Require ping cookies to connect",
415 "reject_after_count",
417 &ConfigFileEntry
.reject_after_count
,
418 "Client rejection threshold setting",
423 &ConfigFileEntry
.reject_ban_time
,
424 "Client rejection time interval",
429 &ConfigFileEntry
.reject_duration
,
430 "Client rejection cache duration",
435 &ConfigFileEntry
.short_motd
,
436 "Do not show MOTD; only tell clients they should read it"
441 &ConfigFileEntry
.stats_e_disabled
,
442 "STATS e output is disabled",
447 &ConfigFileEntry
.stats_c_oper_only
,
448 "STATS C output is only shown to operators",
453 &ConfigFileEntry
.stats_h_oper_only
,
454 "STATS H output is only shown to operators",
459 &ConfigFileEntry
.stats_i_oper_only
,
460 "STATS I output is only shown to operators",
465 &ConfigFileEntry
.stats_k_oper_only
,
466 "STATS K output is only shown to operators",
471 &ConfigFileEntry
.stats_o_oper_only
,
472 "STATS O output is only shown to operators",
477 &ConfigFileEntry
.stats_P_oper_only
,
478 "STATS P is only shown to operators",
483 &ConfigFileEntry
.stats_y_oper_only
,
484 "STATS Y is only shown to operators",
487 "tkline_expire_notices",
489 &ConfigFileEntry
.tkline_expire_notices
,
490 "Notices given to opers when tklines expire"
495 &ConfigFileEntry
.ts_max_delta
,
496 "Maximum permitted TS delta from another server"
501 &ConfigFileEntry
.ts_warn_delta
,
502 "Maximum permitted TS delta before displaying a warning"
507 &ConfigFileEntry
.warn_no_nline
,
508 "Display warning if connecting server lacks N-line"
511 "default_split_server_count",
513 &ConfigChannel
.default_split_server_count
,
514 "Startup value of SPLITNUM",
517 "default_split_user_count",
519 &ConfigChannel
.default_split_user_count
,
520 "Startup value of SPLITUSERS",
525 &ConfigChannel
.knock_delay
,
526 "Delay between a users KNOCK attempts"
529 "knock_delay_channel",
531 &ConfigChannel
.knock_delay_channel
,
532 "Delay between KNOCK attempts to a channel",
535 "kick_on_split_riding",
537 &ConfigChannel
.kick_on_split_riding
,
538 "Kick users riding splits to join +i or +k channels"
543 &ConfigChannel
.max_bans
,
544 "Total +b/e/I/q modes allowed in a channel",
549 &ConfigChannel
.max_bans_large
,
550 "Total +b/e/I/q modes allowed in a +L channel",
553 "max_chans_per_user",
555 &ConfigChannel
.max_chans_per_user
,
556 "Maximum number of channels a user can join",
559 "no_create_on_split",
561 &ConfigChannel
.no_create_on_split
,
562 "Disallow creation of channels when split",
567 &ConfigChannel
.no_join_on_split
,
568 "Disallow joining channels when split",
573 &ConfigChannel
.use_except
,
574 "Enable chanmode +e (ban exceptions)",
579 &ConfigChannel
.use_invex
,
580 "Enable chanmode +I (invite exceptions)",
585 &ConfigChannel
.use_forward
,
586 "Enable chanmode +f (channel forwarding)",
591 &ConfigChannel
.use_knock
,
597 &ConfigServerHide
.disable_hidden
,
598 "Prevent servers from hiding themselves from a flattened /links",
603 &ConfigServerHide
.flatten_links
,
604 "Flatten /links list",
609 &ConfigServerHide
.hidden
,
610 "Hide this server from a flattened /links on remote servers",
615 &ConfigServerHide
.links_delay
,
618 /* --[ END OF TABLE ]---------------------------------------------- */
619 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
625 ** parv[0] = sender prefix
626 ** parv[1] = servername
629 m_info(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
) > CurrentTime
)
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
= CurrentTime
;
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
));
658 ** parv[0] = sender prefix
659 ** parv[1] = servername
662 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
664 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
668 send_info_text(source_p
);
671 send_conf_options(source_p
);
673 send_birthdate_online_time(source_p
);
675 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
684 * inputs - client pointer to send info text to
686 * side effects - info text is sent to client
689 send_info_text(struct Client
*source_p
)
691 const char **text
= infotext
;
695 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
698 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
702 * send_birthdate_online_time
704 * inputs - client pointer to send to
706 * side effects - birthdate and online time are sent
709 send_birthdate_online_time(struct Client
*source_p
)
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
), myctime(startup_time
));
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 config.h)
737 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
739 if(infoptr
->intvalue
)
741 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
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 %-5s [%-30s]",
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 switch (info_table
[i
].output_type
)
765 * For "char *" references
769 char *option
= *((char **) info_table
[i
].option
);
771 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
772 get_id(&me
, source_p
), RPL_INFO
,
773 get_id(source_p
, source_p
),
775 option
? option
: "NONE",
776 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
781 * For "char foo[]" references
783 case OUTPUT_STRING_PTR
:
785 char *option
= (char *) info_table
[i
].option
;
787 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
788 get_id(&me
, source_p
), RPL_INFO
,
789 get_id(source_p
, source_p
),
791 EmptyString(option
) ? "NONE" : option
,
792 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
797 * Output info_table[i].option as a decimal value.
801 int option
= *((int *) info_table
[i
].option
);
803 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
804 get_id(&me
, source_p
), RPL_INFO
,
805 get_id(source_p
, source_p
),
808 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
814 * Output info_table[i].option as "ON" or "OFF"
818 int option
= *((int *) info_table
[i
].option
);
820 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
821 get_id(&me
, source_p
), RPL_INFO
,
822 get_id(source_p
, source_p
),
824 option
? "ON" : "OFF",
825 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
830 * Output info_table[i].option as "YES" or "NO"
832 case OUTPUT_BOOLEAN_YN
:
834 int option
= *((int *) info_table
[i
].option
);
836 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
837 get_id(&me
, source_p
), RPL_INFO
,
838 get_id(source_p
, source_p
),
840 option
? "YES" : "NO",
841 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
846 case OUTPUT_BOOLEAN2
:
848 int option
= *((int *) info_table
[i
].option
);
850 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
851 me
.name
, RPL_INFO
, source_p
->name
,
853 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
854 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
855 } /* switch (info_table[i].output_type) */
860 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
861 ** in order for it to show up properly to opers who issue INFO
864 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
869 * input - pointer to client
871 * side effects - hook doing_info is called
874 info_spy(struct Client
*source_p
)
878 hd
.client
= source_p
;
879 hd
.arg1
= hd
.arg2
= NULL
;
881 call_hook(doing_info_hook
, &hd
);