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
31 #include "irc_string.h"
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
);
47 static int m_info(struct Client
*, struct Client
*, int, const char **);
48 static int mo_info(struct Client
*, struct Client
*, int, const char **);
50 struct Message info_msgtab
= {
51 "INFO", 0, 0, 0, MFLG_SLOW
,
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: 151 $");
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"
95 &ConfigFileEntry
.anti_nick_flood
,
96 "NICK flood protection"
99 "anti_spam_exit_message_time",
101 &ConfigFileEntry
.anti_spam_exit_message_time
,
102 "Duration a client must be connected for to have an exit message"
107 &ConfigFileEntry
.caller_id_wait
,
108 "Minimum delay between notifying UMODE +g users of messages"
113 &ConfigFileEntry
.client_exit
,
114 "Prepend 'Client Exit:' to user QUIT messages"
119 &ConfigFileEntry
.client_flood
,
120 "Number of lines before a client Excess Flood's",
125 &ConfigFileEntry
.connect_timeout
,
126 "Connect timeout for connections to servers"
129 "default_floodcount",
131 &ConfigFileEntry
.default_floodcount
,
132 "Startup value of FLOODCOUNT",
135 "default_adminstring",
137 &ConfigFileEntry
.default_adminstring
,
138 "Default adminstring at startup.",
141 "default_operstring",
143 &ConfigFileEntry
.default_operstring
,
144 "Default operstring at startup.",
149 &ConfigFileEntry
.servicestring
,
150 "String shown in whois for opered services.",
155 &ConfigFileEntry
.disable_auth
,
156 "Controls whether auth checking is disabled or not"
159 "disable_fake_channels",
161 &ConfigFileEntry
.disable_fake_channels
,
162 "Controls whether bold etc are disabled for JOIN"
167 &ConfigFileEntry
.dot_in_ip6_addr
,
168 "Suffix a . to ip6 addresses",
173 &ConfigFileEntry
.dots_in_ident
,
174 "Number of permissable dots in an ident"
177 "failed_oper_notice",
179 &ConfigFileEntry
.failed_oper_notice
,
180 "Inform opers if someone /oper's with the wrong password"
185 &ConfigFileEntry
.fname_userlog
,
191 &ConfigFileEntry
.fname_fuserlog
,
192 "Failed user log file"
198 &ConfigFileEntry
.fname_operlog
,
204 &ConfigFileEntry
.fname_foperlog
,
205 "Failed operator log file"
210 &ConfigFileEntry
.fname_serverlog
,
211 "Server connect/disconnect log file"
216 &ConfigFileEntry
.fname_klinelog
,
222 &ConfigFileEntry
.fname_ioerrorlog
,
228 &ConfigFileEntry
.global_snotices
,
229 "Send out certain server notices globally"
232 "hide_error_messages",
234 &ConfigFileEntry
.hide_error_messages
,
235 "Hide ERROR messages coming from servers"
240 &ConfigFileEntry
.hide_spoof_ips
,
241 "Hide IPs of spoofed users"
252 &ConfigFileEntry
.idletime
,
253 "Number of minutes before a client is considered idle"
258 &ConfigFileEntry
.kline_delay
,
259 "Duration of time to delay kline checking"
264 &ConfigFileEntry
.dline_with_reason
,
265 "Display D-line reason to client on disconnect"
270 &ConfigFileEntry
.kline_with_reason
,
271 "Display K-line reason to client on disconnect"
276 &ConfigFileEntry
.max_accept
,
277 "Maximum nicknames on accept list",
282 &ConfigFileEntry
.max_nick_changes
,
283 "NICK change threshhold setting"
288 &ConfigFileEntry
.max_nick_time
,
289 "NICK flood protection time interval"
294 &ConfigFileEntry
.max_targets
,
295 "The maximum number of PRIVMSG/NOTICE targets"
300 &ConfigFileEntry
.min_nonwildcard
,
301 "Minimum non-wildcard chars in K-lines",
304 "min_nonwildcard_simple",
306 &ConfigFileEntry
.min_nonwildcard_simple
,
307 "Minimum non-wildcard chars in xlines/resvs",
312 &ServerInfo
.network_name
,
318 &ServerInfo
.network_desc
,
319 "Network description"
324 &ConfigFileEntry
.nick_delay
,
325 "Delay nicks are locked for on split",
330 &ConfigFileEntry
.no_oper_flood
,
331 "Disable flood control for operators",
334 "non_redundant_klines",
336 &ConfigFileEntry
.non_redundant_klines
,
337 "Check for and disallow redundant K-lines"
342 &ConfigFileEntry
.pace_wait
,
343 "Minimum delay between uses of certain commands"
348 &ConfigFileEntry
.pace_wait_simple
,
349 "Minimum delay between less intensive commands"
354 &ConfigFileEntry
.ping_cookie
,
355 "Require ping cookies to connect",
358 "reject_after_count",
360 &ConfigFileEntry
.reject_after_count
,
361 "Client rejection threshold setting",
366 &ConfigFileEntry
.reject_ban_time
,
367 "Client rejection time interval",
372 &ConfigFileEntry
.reject_duration
,
373 "Client rejection cache duration",
378 &ConfigFileEntry
.short_motd
,
379 "Do not show MOTD; only tell clients they should read it"
384 &ConfigFileEntry
.stats_e_disabled
,
385 "STATS e output is disabled",
390 &ConfigFileEntry
.stats_c_oper_only
,
391 "STATS C output is only shown to operators",
396 &ConfigFileEntry
.stats_h_oper_only
,
397 "STATS H output is only shown to operators",
402 &ConfigFileEntry
.stats_i_oper_only
,
403 "STATS I output is only shown to operators",
408 &ConfigFileEntry
.stats_k_oper_only
,
409 "STATS K output is only shown to operators",
414 &ConfigFileEntry
.stats_o_oper_only
,
415 "STATS O output is only shown to operators",
420 &ConfigFileEntry
.stats_P_oper_only
,
421 "STATS P is only shown to operators",
426 &ConfigFileEntry
.stats_y_oper_only
,
427 "STATS Y is only shown to operators",
430 "tkline_expire_notices",
432 &ConfigFileEntry
.tkline_expire_notices
,
433 "Notices given to opers when tklines expire"
438 &ConfigFileEntry
.ts_max_delta
,
439 "Maximum permitted TS delta from another server"
444 &ConfigFileEntry
.ts_warn_delta
,
445 "Maximum permitted TS delta before displaying a warning"
450 &ConfigFileEntry
.warn_no_nline
,
451 "Display warning if connecting server lacks N-line"
454 "default_split_server_count",
456 &ConfigChannel
.default_split_server_count
,
457 "Startup value of SPLITNUM",
460 "default_split_user_count",
462 &ConfigChannel
.default_split_user_count
,
463 "Startup value of SPLITUSERS",
468 &ConfigChannel
.knock_delay
,
469 "Delay between a users KNOCK attempts"
472 "knock_delay_channel",
474 &ConfigChannel
.knock_delay_channel
,
475 "Delay between KNOCK attempts to a channel",
480 &ConfigChannel
.invite_ops_only
,
481 "INVITE is restricted to channelops only"
484 "kick_on_split_riding",
486 &ConfigChannel
.kick_on_split_riding
,
487 "Kick users riding splits to join +i or +k channels"
492 &ConfigChannel
.max_bans
,
493 "Total +b/e/I/q modes allowed in a channel",
498 &ConfigChannel
.max_bans_large
,
499 "Total +b/e/I/q modes allowed in a +L channel",
502 "max_chans_per_user",
504 &ConfigChannel
.max_chans_per_user
,
505 "Maximum number of channels a user can join",
508 "no_create_on_split",
510 &ConfigChannel
.no_create_on_split
,
511 "Disallow creation of channels when split",
516 &ConfigChannel
.no_join_on_split
,
517 "Disallow joining channels when split",
522 &ConfigChannel
.use_except
,
523 "Enable chanmode +e (ban exceptions)",
528 &ConfigChannel
.use_invex
,
529 "Enable chanmode +I (invite exceptions)",
534 &ConfigChannel
.use_knock
,
540 &ConfigServerHide
.disable_hidden
,
541 "Prevent servers from hiding themselves from a flattened /links",
546 &ConfigServerHide
.flatten_links
,
547 "Flatten /links list",
552 &ConfigServerHide
.hidden
,
553 "Hide this server from a flattened /links on remote servers",
558 &ConfigServerHide
.links_delay
,
561 /* --[ END OF TABLE ]---------------------------------------------- */
562 { (char *) 0, (unsigned int) 0, (void *) 0, (char *) 0}
568 ** parv[0] = sender prefix
569 ** parv[1] = servername
572 m_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
574 static time_t last_used
= 0L;
576 if((last_used
+ ConfigFileEntry
.pace_wait
) > CurrentTime
)
578 /* safe enough to give this on a local connect only */
579 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
580 me
.name
, source_p
->name
, "INFO");
581 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
585 last_used
= CurrentTime
;
587 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) != HUNTED_ISME
)
590 send_info_text(source_p
);
591 send_birthdate_online_time(source_p
);
593 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
599 ** parv[0] = sender prefix
600 ** parv[1] = servername
603 mo_info(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
605 if(hunt_server(client_p
, source_p
, ":%s INFO :%s", 1, parc
, parv
) == HUNTED_ISME
)
607 send_info_text(source_p
);
609 if(IsOperStaffer(source_p
))
610 send_conf_options(source_p
);
612 send_birthdate_online_time(source_p
);
614 sendto_one_numeric(source_p
, RPL_ENDOFINFO
, form_str(RPL_ENDOFINFO
));
623 * inputs - client pointer to send info text to
625 * side effects - info text is sent to client
628 send_info_text(struct Client
*source_p
)
630 const char **text
= infotext
;
634 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), *text
++);
637 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");
641 * send_birthdate_online_time
643 * inputs - client pointer to send to
645 * side effects - birthdate and online time are sent
648 send_birthdate_online_time(struct Client
*source_p
)
650 sendto_one(source_p
, ":%s %d %s :Birth Date: %s, compile # %s",
651 get_id(&me
, source_p
), RPL_INFO
,
652 get_id(source_p
, source_p
), creation
, generation
);
654 sendto_one(source_p
, ":%s %d %s :On-line since %s",
655 get_id(&me
, source_p
), RPL_INFO
,
656 get_id(source_p
, source_p
), myctime(startup_time
));
662 * inputs - client pointer to send to
664 * side effects - send config options to client
667 send_conf_options(struct Client
*source_p
)
673 * Now send them a list of all our configuration options
674 * (mostly from config.h)
676 for (infoptr
= MyInformation
; infoptr
->name
; infoptr
++)
678 if(infoptr
->intvalue
)
680 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
681 get_id(&me
, source_p
), RPL_INFO
,
682 get_id(source_p
, source_p
),
683 infoptr
->name
, infoptr
->intvalue
,
688 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
689 get_id(&me
, source_p
), RPL_INFO
,
690 get_id(source_p
, source_p
),
691 infoptr
->name
, infoptr
->strvalue
,
697 * Parse the info_table[] and do the magic.
699 for (i
= 0; info_table
[i
].name
; i
++)
701 switch (info_table
[i
].output_type
)
704 * For "char *" references
708 char *option
= *((char **) info_table
[i
].option
);
710 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
711 get_id(&me
, source_p
), RPL_INFO
,
712 get_id(source_p
, source_p
),
714 option
? option
: "NONE",
715 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
720 * For "char foo[]" references
722 case OUTPUT_STRING_PTR
:
724 char *option
= (char *) info_table
[i
].option
;
726 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
727 get_id(&me
, source_p
), RPL_INFO
,
728 get_id(source_p
, source_p
),
730 EmptyString(option
) ? "NONE" : option
,
731 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
736 * Output info_table[i].option as a decimal value.
740 int option
= *((int *) info_table
[i
].option
);
742 sendto_one(source_p
, ":%s %d %s :%-30s %-5d [%-30s]",
743 get_id(&me
, source_p
), RPL_INFO
,
744 get_id(source_p
, source_p
),
747 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
753 * Output info_table[i].option as "ON" or "OFF"
757 int option
= *((int *) info_table
[i
].option
);
759 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
760 get_id(&me
, source_p
), RPL_INFO
,
761 get_id(source_p
, source_p
),
763 option
? "ON" : "OFF",
764 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
769 * Output info_table[i].option as "YES" or "NO"
771 case OUTPUT_BOOLEAN_YN
:
773 int option
= *((int *) info_table
[i
].option
);
775 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
776 get_id(&me
, source_p
), RPL_INFO
,
777 get_id(source_p
, source_p
),
779 option
? "YES" : "NO",
780 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
785 case OUTPUT_BOOLEAN2
:
787 int option
= *((int *) info_table
[i
].option
);
789 sendto_one(source_p
, ":%s %d %s :%-30s %-5s [%-30s]",
790 me
.name
, RPL_INFO
, source_p
->name
,
792 option
? ((option
== 1) ? "MASK" : "YES") : "NO",
793 info_table
[i
].desc
? info_table
[i
].desc
: "<none>");
794 } /* switch (info_table[i].output_type) */
799 /* Don't send oper_only_umodes...it's a bit mask, we will have to decode it
800 ** in order for it to show up properly to opers who issue INFO
803 sendto_one_numeric(source_p
, RPL_INFO
, form_str(RPL_INFO
), "");