ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 5881
Committed: Sun May 3 16:04:15 2015 UTC (8 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 19106 byte(s)
Log Message:
- Use C99-style initializers in all struct Message items
- Removed MFLG_SLOW
- Removed DUMMY_HANDLER

File Contents

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

Properties

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