ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 1767
Committed: Sat Jan 19 18:25:42 2013 UTC (12 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 18603 byte(s)
Log Message:
- INFO now also shows configured values of 'disable_fake_channels',
  and 'stats_e_disabled'

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_info.c: Sends information about the server.
4 *
5 * Copyright (C) 2005 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "channel.h"
28 #include "client.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_serv.h"
33 #include "s_user.h"
34 #include "send.h"
35 #include "conf.h"
36 #include "parse.h"
37 #include "modules.h"
38
39
40 static void send_conf_options(struct Client *);
41 static void send_birthdate_online_time(struct Client *);
42 static void send_info_text(struct Client *);
43
44 /*
45 * jdc -- Structure for our configuration value table
46 */
47 struct InfoStruct
48 {
49 const char *name; /* Displayed variable name */
50 unsigned int output_type; /* See below #defines */
51 void *option; /* Pointer reference to the value */
52 const char *desc; /* ASCII description of the variable */
53 };
54
55 /* Types for output_type in InfoStruct */
56 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
57 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
58 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
59 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
60 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
61 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
62
63 static const struct InfoStruct info_table[] =
64 {
65 /* --[ START OF TABLE ]-------------------------------------------- */
66
67 {
68 "CPATH",
69 OUTPUT_STRING,
70 &ConfigFileEntry.configfile,
71 "Path to main configuration file"
72 },
73 {
74 "DPATH",
75 OUTPUT_STRING,
76 &ConfigFileEntry.dpath,
77 "Directory containing configuration files"
78 },
79 {
80 "DLPATH",
81 OUTPUT_STRING,
82 &ConfigFileEntry.dlinefile,
83 "Path to D-line database file"
84 },
85 {
86 "KPATH",
87 OUTPUT_STRING,
88 &ConfigFileEntry.klinefile,
89 "Path to K-line database file"
90 },
91 {
92 "GPATH",
93 OUTPUT_STRING,
94 &ConfigFileEntry.glinefile,
95 "Path to G-line database file"
96 },
97 {
98 "XPATH",
99 OUTPUT_STRING,
100 &ConfigFileEntry.xlinefile,
101 "Path to X-line database file"
102 },
103 {
104 "RESVPATH",
105 OUTPUT_STRING,
106 &ConfigFileEntry.xlinefile,
107 "Path to resv database file"
108 },
109 {
110 "network_name",
111 OUTPUT_STRING,
112 &ServerInfo.network_name,
113 "Network name"
114 },
115 {
116 "network_desc",
117 OUTPUT_STRING,
118 &ServerInfo.network_desc,
119 "Network description"
120 },
121 {
122 "hub",
123 OUTPUT_BOOLEAN_YN,
124 &ServerInfo.hub,
125 "Server is a hub"
126 },
127 {
128 "max_clients",
129 OUTPUT_DECIMAL,
130 &ServerInfo.max_clients,
131 "Maximum number of clients permitted simultaneously on this server"
132 },
133 {
134 "max_nick_length",
135 OUTPUT_DECIMAL,
136 &ServerInfo.max_nick_length,
137 "Maximum nickname length"
138 },
139 {
140 "max_topic_length",
141 OUTPUT_DECIMAL,
142 &ServerInfo.max_topic_length,
143 "Maximum topic length"
144 },
145 {
146 "use_logging",
147 OUTPUT_BOOLEAN_YN,
148 &ConfigLoggingEntry.use_logging,
149 "Enable logging"
150 },
151 {
152 "disable_fake_channels",
153 OUTPUT_BOOLEAN_YN,
154 &ConfigChannel.disable_fake_channels,
155 "Forbids channels with special ASCII characters in their name"
156 },
157 {
158 "restrict_channels",
159 OUTPUT_BOOLEAN_YN,
160 &ConfigChannel.restrict_channels,
161 "Only reserved channels are allowed"
162 },
163 {
164 "knock_delay",
165 OUTPUT_DECIMAL,
166 &ConfigChannel.knock_delay,
167 "Delay between a users KNOCK attempts"
168 },
169 {
170 "knock_delay_channel",
171 OUTPUT_DECIMAL,
172 &ConfigChannel.knock_delay_channel,
173 "Delay between KNOCK attempts to a channel"
174 },
175 {
176 "max_chans_per_user",
177 OUTPUT_DECIMAL,
178 &ConfigChannel.max_chans_per_user,
179 "Maximum number of channels a user can join"
180 },
181 {
182 "max_chans_per_oper",
183 OUTPUT_DECIMAL,
184 &ConfigChannel.max_chans_per_oper,
185 "Maximum number of channels an oper can join"
186 },
187 {
188 "quiet_on_ban",
189 OUTPUT_BOOLEAN_YN,
190 &ConfigChannel.quiet_on_ban,
191 "Banned users may not send text to a channel"
192 },
193 {
194 "max_bans",
195 OUTPUT_DECIMAL,
196 &ConfigChannel.max_bans,
197 "Total +b/e/I modes allowed in a channel"
198 },
199 {
200 "default_split_user_count",
201 OUTPUT_DECIMAL,
202 &ConfigChannel.default_split_user_count,
203 "Startup value of SPLITUSERS"
204 },
205 {
206 "default_split_server_count",
207 OUTPUT_DECIMAL,
208 &ConfigChannel.default_split_server_count,
209 "Startup value of SPLITNUM"
210 },
211 {
212 "no_create_on_split",
213 OUTPUT_BOOLEAN_YN,
214 &ConfigChannel.no_create_on_split,
215 "Disallow creation of channels when split"
216 },
217 {
218 "no_join_on_split",
219 OUTPUT_BOOLEAN_YN,
220 &ConfigChannel.no_join_on_split,
221 "Disallow joining channels when split"
222 },
223 {
224 "flatten_links",
225 OUTPUT_BOOLEAN_YN,
226 &ConfigServerHide.flatten_links,
227 "Flatten /links list"
228 },
229 {
230 "links_delay",
231 OUTPUT_DECIMAL,
232 &ConfigServerHide.links_delay,
233 "Links rehash delay"
234 },
235 {
236 "hidden",
237 OUTPUT_BOOLEAN_YN,
238 &ConfigServerHide.hidden,
239 "Hide this server from a flattened /links on remote servers"
240 },
241 {
242 "hide_servers",
243 OUTPUT_BOOLEAN_YN,
244 &ConfigServerHide.hide_servers,
245 "Hide servernames from users"
246 },
247 {
248 "hidden_name",
249 OUTPUT_STRING,
250 &ConfigServerHide.hidden_name,
251 "Server name users see if hide_servers = yes"
252 },
253 {
254 "hide_server_ips",
255 OUTPUT_BOOLEAN_YN,
256 &ConfigServerHide.hide_server_ips,
257 "Prevent people from seeing server IPs"
258 },
259 {
260 "gline_min_cidr",
261 OUTPUT_DECIMAL,
262 &ConfigFileEntry.gline_min_cidr,
263 "Minimum required length of a CIDR bitmask for IPv4 G-Lines"
264 },
265 {
266 "gline_min_cidr6",
267 OUTPUT_DECIMAL,
268 &ConfigFileEntry.gline_min_cidr6,
269 "Minimum required length of a CIDR bitmask for IPv6 G-Lines"
270 },
271 {
272 "invisible_on_connect",
273 OUTPUT_BOOLEAN_YN,
274 &ConfigFileEntry.invisible_on_connect,
275 "Automatically set mode +i on connecting users"
276 },
277 {
278 "kill_chase_time_limit",
279 OUTPUT_DECIMAL,
280 &ConfigFileEntry.kill_chase_time_limit,
281 "Nick Change Tracker for KILL"
282 },
283 {
284 "hide_spoof_ips",
285 OUTPUT_BOOLEAN_YN,
286 &ConfigFileEntry.hide_spoof_ips,
287 "Hide spoofed IP's"
288 },
289 {
290 "ignore_bogus_ts",
291 OUTPUT_BOOLEAN_YN,
292 &ConfigFileEntry.ignore_bogus_ts,
293 "Ignore bogus timestamps from other servers"
294 },
295 {
296 "disable_auth",
297 OUTPUT_BOOLEAN_YN,
298 &ConfigFileEntry.disable_auth,
299 "Completely disable ident lookups"
300 },
301 {
302 "disable_remote_commands",
303 OUTPUT_BOOLEAN_YN,
304 &ConfigFileEntry.disable_remote,
305 "Prevent users issuing commands on remote servers"
306 },
307 {
308 "tkline_expire_notices",
309 OUTPUT_BOOLEAN_YN,
310 &ConfigFileEntry.tkline_expire_notices,
311 "Show temporary kline/xline expire notices"
312 },
313 {
314 "default_floodcount",
315 OUTPUT_DECIMAL,
316 &ConfigFileEntry.default_floodcount,
317 "Startup value of FLOODCOUNT"
318 },
319 {
320 "failed_oper_notice",
321 OUTPUT_BOOLEAN,
322 &ConfigFileEntry.failed_oper_notice,
323 "Inform opers if someone tries to /oper with the wrong password"
324 },
325 {
326 "dots_in_ident",
327 OUTPUT_DECIMAL,
328 &ConfigFileEntry.dots_in_ident,
329 "Number of permissable dots in an ident"
330 },
331 {
332 "min_nonwildcard",
333 OUTPUT_DECIMAL,
334 &ConfigFileEntry.min_nonwildcard,
335 "Minimum non-wildcard chars in K/G lines"
336 },
337 {
338 "min_nonwildcard_simple",
339 OUTPUT_DECIMAL,
340 &ConfigFileEntry.min_nonwildcard_simple,
341 "Minimum non-wildcards in gecos bans"
342 },
343 {
344 "max_accept",
345 OUTPUT_DECIMAL,
346 &ConfigFileEntry.max_accept,
347 "Maximum nicknames on accept list"
348 },
349 {
350 "anti_nick_flood",
351 OUTPUT_BOOLEAN,
352 &ConfigFileEntry.anti_nick_flood,
353 "NICK flood protection"
354 },
355 {
356 "max_nick_time",
357 OUTPUT_DECIMAL,
358 &ConfigFileEntry.max_nick_time,
359 "NICK flood protection time interval"
360 },
361 {
362 "max_nick_changes",
363 OUTPUT_DECIMAL,
364 &ConfigFileEntry.max_nick_changes,
365 "NICK change threshhold setting"
366 },
367 {
368 "anti_spam_exit_message_time",
369 OUTPUT_DECIMAL,
370 &ConfigFileEntry.anti_spam_exit_message_time,
371 "Duration a client must be connected for to have an exit message"
372 },
373 {
374 "ts_warn_delta",
375 OUTPUT_DECIMAL,
376 &ConfigFileEntry.ts_warn_delta,
377 "Maximum permitted TS delta before displaying a warning"
378 },
379 {
380 "ts_max_delta",
381 OUTPUT_DECIMAL,
382 &ConfigFileEntry.ts_max_delta,
383 "Maximum permitted TS delta from another server"
384 },
385 {
386 "warn_no_nline",
387 OUTPUT_BOOLEAN,
388 &ConfigFileEntry.warn_no_nline,
389 "Display warning if connecting server lacks N-line"
390 },
391 {
392 "stats_e_disabled",
393 OUTPUT_BOOLEAN_YN,
394 &ConfigFileEntry.stats_e_disabled,
395 "Whether or not STATS e is disabled"
396 },
397 {
398 "stats_o_oper_only",
399 OUTPUT_BOOLEAN_YN,
400 &ConfigFileEntry.stats_o_oper_only,
401 "STATS O output is only shown to operators"
402 },
403 {
404 "stats_P_oper_only",
405 OUTPUT_BOOLEAN_YN,
406 &ConfigFileEntry.stats_P_oper_only,
407 "STATS P is only shown to operators"
408 },
409 {
410 "stats_i_oper_only",
411 OUTPUT_BOOLEAN2,
412 &ConfigFileEntry.stats_i_oper_only,
413 "STATS I output is only shown to operators"
414 },
415 {
416 "stats_k_oper_only",
417 OUTPUT_BOOLEAN2,
418 &ConfigFileEntry.stats_k_oper_only,
419 "STATS K output is only shown to operators"
420 },
421 {
422 "caller_id_wait",
423 OUTPUT_DECIMAL,
424 &ConfigFileEntry.caller_id_wait,
425 "Minimum delay between notifying UMODE +g users of messages"
426 },
427 {
428 "opers_bypass_callerid",
429 OUTPUT_BOOLEAN_YN,
430 &ConfigFileEntry.opers_bypass_callerid,
431 "Allows IRC operators to message users who are +g (callerid)"
432 },
433 {
434 "pace_wait_simple",
435 OUTPUT_DECIMAL,
436 &ConfigFileEntry.pace_wait_simple,
437 "Minimum delay between less intensive commands"
438 },
439 {
440 "pace_wait",
441 OUTPUT_DECIMAL,
442 &ConfigFileEntry.pace_wait,
443 "Minimum delay between uses of certain commands"
444 },
445 {
446 "short_motd",
447 OUTPUT_BOOLEAN_YN,
448 &ConfigFileEntry.short_motd,
449 "Do not show MOTD; only tell clients they should read it"
450 },
451 {
452 "ping_cookie",
453 OUTPUT_BOOLEAN,
454 &ConfigFileEntry.ping_cookie,
455 "Require ping cookies to connect"
456 },
457 {
458 "no_oper_flood",
459 OUTPUT_BOOLEAN,
460 &ConfigFileEntry.no_oper_flood,
461 "Reduce flood control for operators"
462 },
463 {
464 "true_no_oper_flood",
465 OUTPUT_BOOLEAN,
466 &ConfigFileEntry.true_no_oper_flood,
467 "Completely disable flood control for operators"
468 },
469 {
470 "oper_pass_resv",
471 OUTPUT_BOOLEAN_YN,
472 &ConfigFileEntry.oper_pass_resv,
473 "Opers can over-ride RESVs"
474 },
475 {
476 "max_targets",
477 OUTPUT_DECIMAL,
478 &ConfigFileEntry.max_targets,
479 "The maximum number of PRIVMSG/NOTICE targets"
480 },
481 {
482 "throttle_time",
483 OUTPUT_DECIMAL,
484 &ConfigFileEntry.throttle_time,
485 "Minimum time between client reconnects"
486 },
487 {
488 "glines",
489 OUTPUT_BOOLEAN,
490 &ConfigFileEntry.glines,
491 "G-line (network-wide K-line) support"
492 },
493 {
494 "gline_duration",
495 OUTPUT_DECIMAL,
496 &ConfigFileEntry.gline_time,
497 "Expiry time for G-lines"
498 },
499
500 {
501 "gline_request_duration",
502 OUTPUT_DECIMAL,
503 &ConfigFileEntry.gline_request_time,
504 "Expiry time for pending G-lines"
505 },
506
507 /* --[ END OF TABLE ]---------------------------------------------- */
508 {
509 NULL,
510 0,
511 NULL,
512 0
513 }
514 };
515
516 /*
517 ** m_info()
518 ** parv[0] = sender prefix
519 ** parv[1] = servername
520 */
521 static void
522 m_info(struct Client *client_p, struct Client *source_p,
523 int parc, char *parv[])
524 {
525 static time_t last_used = 0;
526
527 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
528 {
529 /* safe enough to give this on a local connect only */
530 sendto_one(source_p, form_str(RPL_LOAD2HI),
531 me.name, source_p->name);
532 return;
533 }
534
535 last_used = CurrentTime;
536
537 if (!ConfigFileEntry.disable_remote)
538 if (hunt_server(client_p,source_p, ":%s INFO :%s", 1,
539 parc, parv) != HUNTED_ISME)
540 return;
541
542 send_info_text(source_p);
543 }
544
545 /*
546 ** mo_info()
547 ** parv[0] = sender prefix
548 ** parv[1] = servername
549 */
550 static void
551 mo_info(struct Client *client_p, struct Client *source_p,
552 int parc, char *parv[])
553 {
554 if (hunt_server(client_p, source_p, ":%s INFO :%s", 1,
555 parc, parv) != HUNTED_ISME)
556 return;
557
558 send_info_text(source_p);
559 }
560
561 /*
562 ** ms_info()
563 ** parv[0] = sender prefix
564 ** parv[1] = servername
565 */
566 static void
567 ms_info(struct Client *client_p, struct Client *source_p,
568 int parc, char *parv[])
569 {
570 if (!IsClient(source_p))
571 return;
572
573 if (hunt_server(client_p, source_p, ":%s INFO :%s", 1,
574 parc, parv) != HUNTED_ISME)
575 return;
576
577 send_info_text(source_p);
578 }
579
580 /* send_info_text()
581 *
582 * inputs - client pointer to send info text to
583 * output - NONE
584 * side effects - info text is sent to client
585 */
586 static void
587 send_info_text(struct Client *source_p)
588 {
589 const char **text = infotext;
590 char *source, *target;
591
592 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
593 "INFO requested by %s (%s@%s) [%s]",
594 source_p->name, source_p->username,
595 source_p->host, source_p->servptr->name);
596
597 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) &&
598 HasID(source_p))
599 source = me.id, target = source_p->id;
600 else
601 source = me.name, target = source_p->name;
602
603 while (*text)
604 {
605 const char *line = *text++;
606
607 if (*line == '\0')
608 line = " ";
609
610 sendto_one(source_p, form_str(RPL_INFO),
611 source, target, line);
612 }
613
614 if (HasUMode(source_p, UMODE_OPER))
615 send_conf_options(source_p);
616
617 send_birthdate_online_time(source_p);
618
619 sendto_one(source_p, form_str(RPL_ENDOFINFO),
620 me.name, source_p->name);
621 }
622
623 /* send_birthdate_online_time()
624 *
625 * inputs - client pointer to send to
626 * output - NONE
627 * side effects - birthdate and online time are sent
628 */
629 static void
630 send_birthdate_online_time(struct Client *source_p)
631 {
632 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
633 {
634 sendto_one(source_p, ":%s %d %s :On-line since %s",
635 me.id, RPL_INFO, source_p->id,
636 myctime(me.localClient->firsttime));
637 }
638 else
639 {
640 sendto_one(source_p, ":%s %d %s :On-line since %s",
641 me.name, RPL_INFO, source_p->name,
642 myctime(me.localClient->firsttime));
643 }
644 }
645
646 /* send_conf_options()
647 *
648 * inputs - client pointer to send to
649 * output - NONE
650 * side effects - send config options to client
651 */
652 static void
653 send_conf_options(struct Client *source_p)
654 {
655 const char *from, *to;
656 const struct InfoStruct *iptr = NULL;
657
658 /* Now send them a list of all our configuration options
659 * (mostly from defaults.h and config.h)
660 */
661 if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
662 {
663 from = me.id;
664 to = source_p->id;
665 }
666 else
667 {
668 from = me.name;
669 to = source_p->name;
670 }
671
672 /*
673 * Parse the info_table[] and do the magic.
674 */
675 for (iptr = info_table; iptr->name; ++iptr)
676 {
677 switch (iptr->output_type)
678 {
679 /* For "char *" references */
680 case OUTPUT_STRING:
681 {
682 const char *option = *((char **)iptr->option);
683
684 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
685 from, RPL_INFO, to,
686 iptr->name, option ? option : "NONE",
687 iptr->desc ? iptr->desc : "<none>");
688 break;
689 }
690
691 /* For "char foo[]" references */
692 case OUTPUT_STRING_PTR:
693 {
694 const char *option = iptr->option;
695
696 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
697 from, RPL_INFO, to,
698 iptr->name, option ? option : "NONE",
699 iptr->desc ? iptr->desc : "<none>");
700 break;
701 }
702
703 /* Output info_table[i].option as a decimal value. */
704 case OUTPUT_DECIMAL:
705 {
706 const int option = *((int *)iptr->option);
707
708 sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
709 from, RPL_INFO, to, iptr->name,
710 option, iptr->desc ? iptr->desc : "<none>");
711 break;
712 }
713
714 /* Output info_table[i].option as "ON" or "OFF" */
715 case OUTPUT_BOOLEAN:
716 {
717 const int option = *((int *)iptr->option);
718
719 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
720 from, RPL_INFO, to,
721 iptr->name, option ? "ON" : "OFF",
722 iptr->desc ? iptr->desc : "<none>");
723
724 break;
725 }
726
727 /* Output info_table[i].option as "YES" or "NO" */
728 case OUTPUT_BOOLEAN_YN:
729 {
730 int option = *((int *)iptr->option);
731
732 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
733 from, RPL_INFO, to,
734 iptr->name, option ? "YES" : "NO",
735 iptr->desc ? iptr->desc : "<none>");
736 break;
737 }
738
739 case OUTPUT_BOOLEAN2:
740 {
741 int option = *((int *)iptr->option);
742
743 sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
744 from, RPL_INFO, to,
745 iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO",
746 iptr->desc ? iptr->desc : "<none>");
747 break;
748 }
749 }
750 }
751
752 sendto_one(source_p, form_str(RPL_INFO),
753 from, to, "");
754 }
755
756 static struct Message info_msgtab = {
757 "INFO", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
758 { m_unregistered, m_info, ms_info, m_ignore, mo_info, m_ignore }
759 };
760
761 static void
762 module_init(void)
763 {
764 mod_add_cmd(&info_msgtab);
765 }
766
767 static void
768 module_exit(void)
769 {
770 mod_del_cmd(&info_msgtab);
771 }
772
773 struct module module_entry = {
774 .node = { NULL, NULL, NULL },
775 .name = NULL,
776 .version = "$Revision$",
777 .handle = NULL,
778 .modinit = module_init,
779 .modexit = module_exit,
780 .flags = 0
781 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision