ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 3117
Committed: Fri Mar 7 19:28:54 2014 UTC (10 years, 1 month ago) by michael
Content type: text/x-csrc
File size: 17724 byte(s)
Log Message:
- Removed unused header includes here and there

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

Properties

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