ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 3347
Committed: Sun Apr 20 14:03:06 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 18722 byte(s)
Log Message:
- Moved files:
  s_user.c -> user.c
  s_misc.c -> misc.c
  s_serv.c -> server.c

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 /*
41 * jdc -- Structure for our configuration value table
42 */
43 struct InfoStruct
44 {
45 const char *name; /* Displayed variable name */
46 const unsigned int output_type; /* See below #defines */
47 const void *option; /* Pointer reference to the value */
48 const char *desc; /* ASCII description of the variable */
49 };
50
51 /* Types for output_type in InfoStruct */
52 #define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */
53 #define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */
54 #define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */
55 #define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */
56 #define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */
57 #define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */
58
59 static const struct InfoStruct info_table[] =
60 {
61 /* --[ START OF TABLE ]-------------------------------------------- */
62
63 {
64 "DPATH",
65 OUTPUT_STRING,
66 &ConfigFileEntry.dpath,
67 "Root directory of installation"
68 },
69 {
70 "SPATH",
71 OUTPUT_STRING,
72 &ConfigFileEntry.spath,
73 "Path to server executable"
74 },
75 {
76 "MPATH",
77 OUTPUT_STRING,
78 &ConfigFileEntry.mpath,
79 "Path to main motd (Message of the Day) file"
80 },
81 {
82 "CPATH",
83 OUTPUT_STRING,
84 &ConfigFileEntry.configfile,
85 "Path to main configuration file"
86 },
87 {
88 "DLPATH",
89 OUTPUT_STRING,
90 &ConfigFileEntry.dlinefile,
91 "Path to D-line database file"
92 },
93 {
94 "KPATH",
95 OUTPUT_STRING,
96 &ConfigFileEntry.klinefile,
97 "Path to K-line database file"
98 },
99 {
100 "GPATH",
101 OUTPUT_STRING,
102 &ConfigFileEntry.glinefile,
103 "Path to G-line database file"
104 },
105 {
106 "XPATH",
107 OUTPUT_STRING,
108 &ConfigFileEntry.xlinefile,
109 "Path to X-line database file"
110 },
111 {
112 "RESVPATH",
113 OUTPUT_STRING,
114 &ConfigFileEntry.resvfile,
115 "Path to resv database file"
116 },
117 {
118 "network_name",
119 OUTPUT_STRING,
120 &ServerInfo.network_name,
121 "Network name"
122 },
123 {
124 "network_desc",
125 OUTPUT_STRING,
126 &ServerInfo.network_desc,
127 "Network description"
128 },
129 {
130 "hub",
131 OUTPUT_BOOLEAN_YN,
132 &ServerInfo.hub,
133 "Server is a hub"
134 },
135 {
136 "max_clients",
137 OUTPUT_DECIMAL,
138 &ServerInfo.max_clients,
139 "Maximum number of clients permitted simultaneously on this server"
140 },
141 {
142 "max_nick_length",
143 OUTPUT_DECIMAL,
144 &ServerInfo.max_nick_length,
145 "Maximum nickname length"
146 },
147 {
148 "max_topic_length",
149 OUTPUT_DECIMAL,
150 &ServerInfo.max_topic_length,
151 "Maximum topic length"
152 },
153 {
154 "use_logging",
155 OUTPUT_BOOLEAN_YN,
156 &ConfigLoggingEntry.use_logging,
157 "Enable logging"
158 },
159 {
160 "disable_fake_channels",
161 OUTPUT_BOOLEAN_YN,
162 &ConfigChannel.disable_fake_channels,
163 "Forbids channels with special ASCII characters in their name"
164 },
165 {
166 "knock_delay",
167 OUTPUT_DECIMAL,
168 &ConfigChannel.knock_delay,
169 "Delay between a users KNOCK attempts"
170 },
171 {
172 "knock_delay_channel",
173 OUTPUT_DECIMAL,
174 &ConfigChannel.knock_delay_channel,
175 "Delay between KNOCK attempts to a channel"
176 },
177 {
178 "max_chans_per_user",
179 OUTPUT_DECIMAL,
180 &ConfigChannel.max_chans_per_user,
181 "Maximum number of channels a user can join"
182 },
183 {
184 "max_chans_per_oper",
185 OUTPUT_DECIMAL,
186 &ConfigChannel.max_chans_per_oper,
187 "Maximum number of channels an oper can join"
188 },
189 {
190 "max_bans",
191 OUTPUT_DECIMAL,
192 &ConfigChannel.max_bans,
193 "Total +b/e/I modes allowed in a channel"
194 },
195 {
196 "default_split_user_count",
197 OUTPUT_DECIMAL,
198 &ConfigChannel.default_split_user_count,
199 "Startup value of SPLITUSERS"
200 },
201 {
202 "default_split_server_count",
203 OUTPUT_DECIMAL,
204 &ConfigChannel.default_split_server_count,
205 "Startup value of SPLITNUM"
206 },
207 {
208 "no_create_on_split",
209 OUTPUT_BOOLEAN_YN,
210 &ConfigChannel.no_create_on_split,
211 "Disallow creation of channels when split"
212 },
213 {
214 "no_join_on_split",
215 OUTPUT_BOOLEAN_YN,
216 &ConfigChannel.no_join_on_split,
217 "Disallow joining channels when split"
218 },
219 {
220 "flatten_links",
221 OUTPUT_BOOLEAN_YN,
222 &ConfigServerHide.flatten_links,
223 "Flatten /links list"
224 },
225 {
226 "links_delay",
227 OUTPUT_DECIMAL,
228 &ConfigServerHide.links_delay,
229 "Links rehash delay"
230 },
231 {
232 "hidden",
233 OUTPUT_BOOLEAN_YN,
234 &ConfigServerHide.hidden,
235 "Hide this server from a flattened /links on remote servers"
236 },
237 {
238 "hide_servers",
239 OUTPUT_BOOLEAN_YN,
240 &ConfigServerHide.hide_servers,
241 "Hide servernames from users"
242 },
243 {
244 "hide_services",
245 OUTPUT_BOOLEAN_YN,
246 &ConfigServerHide.hide_services,
247 "Hides the location of services server"
248 },
249 {
250 "hidden_name",
251 OUTPUT_STRING,
252 &ConfigServerHide.hidden_name,
253 "Server name users see if hide_servers = yes"
254 },
255 {
256 "hide_server_ips",
257 OUTPUT_BOOLEAN_YN,
258 &ConfigServerHide.hide_server_ips,
259 "Prevent people from seeing server IP addresses"
260 },
261 {
262 "gline_min_cidr",
263 OUTPUT_DECIMAL,
264 &ConfigFileEntry.gline_min_cidr,
265 "Minimum required length of a CIDR bitmask for IPv4 G-Lines"
266 },
267 {
268 "gline_min_cidr6",
269 OUTPUT_DECIMAL,
270 &ConfigFileEntry.gline_min_cidr6,
271 "Minimum required length of a CIDR bitmask for IPv6 G-Lines"
272 },
273 {
274 "invisible_on_connect",
275 OUTPUT_BOOLEAN_YN,
276 &ConfigFileEntry.invisible_on_connect,
277 "Automatically set mode +i on connecting users"
278 },
279 {
280 "kill_chase_time_limit",
281 OUTPUT_DECIMAL,
282 &ConfigFileEntry.kill_chase_time_limit,
283 "Nick Change Tracker for KILL"
284 },
285 {
286 "hide_spoof_ips",
287 OUTPUT_BOOLEAN_YN,
288 &ConfigFileEntry.hide_spoof_ips,
289 "Hide spoofed IP addresses"
290 },
291 {
292 "ignore_bogus_ts",
293 OUTPUT_BOOLEAN_YN,
294 &ConfigFileEntry.ignore_bogus_ts,
295 "Ignore bogus timestamps from other servers"
296 },
297 {
298 "cycle_on_host_change",
299 OUTPUT_BOOLEAN_YN,
300 &ConfigFileEntry.cycle_on_host_change,
301 "Send a fake QUIT/JOIN combination on host change"
302 },
303 {
304 "disable_auth",
305 OUTPUT_BOOLEAN_YN,
306 &ConfigFileEntry.disable_auth,
307 "Completely disable ident lookups"
308 },
309 {
310 "disable_remote_commands",
311 OUTPUT_BOOLEAN_YN,
312 &ConfigServerHide.disable_remote_commands,
313 "Prevent users issuing commands on remote servers"
314 },
315 {
316 "tkline_expire_notices",
317 OUTPUT_BOOLEAN_YN,
318 &ConfigFileEntry.tkline_expire_notices,
319 "Show temporary kline/xline expire notices"
320 },
321 {
322 "default_floodcount",
323 OUTPUT_DECIMAL,
324 &ConfigFileEntry.default_floodcount,
325 "Startup value of FLOODCOUNT"
326 },
327 {
328 "failed_oper_notice",
329 OUTPUT_BOOLEAN,
330 &ConfigFileEntry.failed_oper_notice,
331 "Inform opers if someone tries to /oper with the wrong password"
332 },
333 {
334 "dots_in_ident",
335 OUTPUT_DECIMAL,
336 &ConfigFileEntry.dots_in_ident,
337 "Number of permissable dots in an ident"
338 },
339 {
340 "min_nonwildcard",
341 OUTPUT_DECIMAL,
342 &ConfigFileEntry.min_nonwildcard,
343 "Minimum non-wildcard chars in K/G lines"
344 },
345 {
346 "min_nonwildcard_simple",
347 OUTPUT_DECIMAL,
348 &ConfigFileEntry.min_nonwildcard_simple,
349 "Minimum non-wildcards in gecos bans"
350 },
351 {
352 "max_accept",
353 OUTPUT_DECIMAL,
354 &ConfigFileEntry.max_accept,
355 "Maximum nicknames on accept list"
356 },
357 {
358 "anti_nick_flood",
359 OUTPUT_BOOLEAN,
360 &ConfigFileEntry.anti_nick_flood,
361 "NICK flood protection"
362 },
363 {
364 "max_nick_time",
365 OUTPUT_DECIMAL,
366 &ConfigFileEntry.max_nick_time,
367 "NICK flood protection time interval"
368 },
369 {
370 "max_nick_changes",
371 OUTPUT_DECIMAL,
372 &ConfigFileEntry.max_nick_changes,
373 "NICK change threshhold setting"
374 },
375 {
376 "anti_spam_exit_message_time",
377 OUTPUT_DECIMAL,
378 &ConfigFileEntry.anti_spam_exit_message_time,
379 "Duration a client must be connected for to have an exit message"
380 },
381 {
382 "ts_warn_delta",
383 OUTPUT_DECIMAL,
384 &ConfigFileEntry.ts_warn_delta,
385 "Maximum permitted TS delta before displaying a warning"
386 },
387 {
388 "ts_max_delta",
389 OUTPUT_DECIMAL,
390 &ConfigFileEntry.ts_max_delta,
391 "Maximum permitted TS delta from another server"
392 },
393 {
394 "warn_no_nline",
395 OUTPUT_BOOLEAN,
396 &ConfigFileEntry.warn_no_nline,
397 "Display warning if connecting server lacks N-line"
398 },
399 {
400 "stats_e_disabled",
401 OUTPUT_BOOLEAN_YN,
402 &ConfigFileEntry.stats_e_disabled,
403 "Whether or not STATS e is disabled"
404 },
405 {
406 "stats_o_oper_only",
407 OUTPUT_BOOLEAN_YN,
408 &ConfigFileEntry.stats_o_oper_only,
409 "STATS O output is only shown to operators"
410 },
411 {
412 "stats_P_oper_only",
413 OUTPUT_BOOLEAN_YN,
414 &ConfigFileEntry.stats_P_oper_only,
415 "STATS P is only shown to operators"
416 },
417 {
418 "stats_u_oper_only",
419 OUTPUT_BOOLEAN_YN,
420 &ConfigFileEntry.stats_u_oper_only,
421 "STATS u is only shown to operators"
422 },
423 {
424 "stats_i_oper_only",
425 OUTPUT_BOOLEAN2,
426 &ConfigFileEntry.stats_i_oper_only,
427 "STATS I output is only shown to operators"
428 },
429 {
430 "stats_k_oper_only",
431 OUTPUT_BOOLEAN2,
432 &ConfigFileEntry.stats_k_oper_only,
433 "STATS K output is only shown to operators"
434 },
435 {
436 "caller_id_wait",
437 OUTPUT_DECIMAL,
438 &ConfigFileEntry.caller_id_wait,
439 "Minimum delay between notifying UMODE +g users of messages"
440 },
441 {
442 "opers_bypass_callerid",
443 OUTPUT_BOOLEAN_YN,
444 &ConfigFileEntry.opers_bypass_callerid,
445 "Allows IRC operators to message users who are +g (callerid)"
446 },
447 {
448 "pace_wait_simple",
449 OUTPUT_DECIMAL,
450 &ConfigFileEntry.pace_wait_simple,
451 "Minimum delay between less intensive commands"
452 },
453 {
454 "pace_wait",
455 OUTPUT_DECIMAL,
456 &ConfigFileEntry.pace_wait,
457 "Minimum delay between uses of certain commands"
458 },
459 {
460 "short_motd",
461 OUTPUT_BOOLEAN_YN,
462 &ConfigFileEntry.short_motd,
463 "Do not show MOTD; only tell clients they should read it"
464 },
465 {
466 "ping_cookie",
467 OUTPUT_BOOLEAN,
468 &ConfigFileEntry.ping_cookie,
469 "Require ping cookies to connect"
470 },
471 {
472 "no_oper_flood",
473 OUTPUT_BOOLEAN,
474 &ConfigFileEntry.no_oper_flood,
475 "Reduce flood control for operators"
476 },
477 {
478 "true_no_oper_flood",
479 OUTPUT_BOOLEAN,
480 &ConfigFileEntry.true_no_oper_flood,
481 "Completely disable flood control for operators"
482 },
483 {
484 "oper_pass_resv",
485 OUTPUT_BOOLEAN_YN,
486 &ConfigFileEntry.oper_pass_resv,
487 "Opers can over-ride RESVs"
488 },
489 {
490 "max_targets",
491 OUTPUT_DECIMAL,
492 &ConfigFileEntry.max_targets,
493 "The maximum number of PRIVMSG/NOTICE targets"
494 },
495 {
496 "throttle_time",
497 OUTPUT_DECIMAL,
498 &ConfigFileEntry.throttle_time,
499 "Minimum time between client reconnects"
500 },
501 {
502 "glines",
503 OUTPUT_BOOLEAN,
504 &ConfigFileEntry.glines,
505 "G-line (network-wide K-line) support"
506 },
507 {
508 "gline_duration",
509 OUTPUT_DECIMAL,
510 &ConfigFileEntry.gline_time,
511 "Expiry time for G-lines"
512 },
513 {
514 "gline_request_duration",
515 OUTPUT_DECIMAL,
516 &ConfigFileEntry.gline_request_time,
517 "Expiry time for pending G-lines"
518 },
519
520 /* --[ END OF TABLE ]---------------------------------------------- */
521 {
522 NULL,
523 0,
524 NULL,
525 0
526 }
527 };
528
529 /* send_birthdate_online_time()
530 *
531 * inputs - client pointer to send to
532 * output - NONE
533 * side effects - birthdate and online time are sent
534 */
535 static void
536 send_birthdate_online_time(struct Client *source_p)
537 {
538 sendto_one(source_p, ":%s %d %s :On-line since %s",
539 ID_or_name(&me, source_p), RPL_INFO,
540 ID_or_name(source_p, source_p),
541 myctime(me.localClient->firsttime));
542 }
543
544 /* send_conf_options()
545 *
546 * inputs - client pointer to send to
547 * output - NONE
548 * side effects - send config options to client
549 */
550 static void
551 send_conf_options(struct Client *source_p)
552 {
553 const struct InfoStruct *iptr = NULL;
554
555 /*
556 * Parse the info_table[] and do the magic.
557 */
558 for (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(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
568 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
580 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
592 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
603 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
616 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
627 ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p),
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