/[svn]/ircd-hybrid/branches/8.0.x/modules/m_info.c
ViewVC logotype

Contents of /ircd-hybrid/branches/8.0.x/modules/m_info.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1766 - (show annotations)
Sat Jan 19 18:22:39 2013 UTC (7 years, 8 months ago) by michael
File MIME type: text/x-chdr
File size: 18240 byte(s)
- INFO now also shows configured values of 'disable_fake_channels',
  and 'stats_e_disabled'


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

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28