ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 6375
Committed: Fri Aug 21 10:34:16 2015 UTC (10 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 18615 byte(s)
Log Message:
- Remove splitmode checking

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

Properties

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