/[svn]/ircd-hybrid/trunk/modules/m_info.c
ViewVC logotype

Contents of /ircd-hybrid/trunk/modules/m_info.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1702 - (show annotations)
Thu Dec 20 15:49:20 2012 UTC (7 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 17919 byte(s)
- /info now also shows pathnames of g-/x-line database files

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

Properties

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

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