ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 3742
Committed: Sun Jun 1 16:38:45 2014 UTC (11 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 18531 byte(s)
Log Message:
- m_info.c: style corrections; make things use an enum

File Contents

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

Properties

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