ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 1946
Committed: Sun May 5 10:21:40 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 18011 byte(s)
Log Message:
- Removed channel::quiet_on_ban configuration option. This feature is
  now enabled by default

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_info.c: Sends information about the server.
4     *
5     * Copyright (C) 2005 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26 michael 1011 #include "list.h"
27 adx 30 #include "channel.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "s_serv.h"
33     #include "s_user.h"
34     #include "send.h"
35 michael 1309 #include "conf.h"
36 adx 30 #include "parse.h"
37     #include "modules.h"
38    
39 michael 1230
40 adx 30 /*
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 michael 1827 #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 adx 30
59     static const struct InfoStruct info_table[] =
60     {
61     /* --[ START OF TABLE ]-------------------------------------------- */
62 michael 1318
63 adx 30 {
64 michael 1318 "CPATH",
65     OUTPUT_STRING,
66     &ConfigFileEntry.configfile,
67 michael 1702 "Path to main configuration file"
68 michael 1318 },
69     {
70     "DPATH",
71     OUTPUT_STRING,
72     &ConfigFileEntry.dpath,
73 michael 1841 "Root directory of installation"
74 michael 1318 },
75     {
76     "DLPATH",
77     OUTPUT_STRING,
78     &ConfigFileEntry.dlinefile,
79 michael 1702 "Path to D-line database file"
80 michael 1318 },
81     {
82     "KPATH",
83     OUTPUT_STRING,
84     &ConfigFileEntry.klinefile,
85 michael 1702 "Path to K-line database file"
86 michael 1318 },
87     {
88 michael 1702 "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 michael 1841 &ConfigFileEntry.resvfile,
103 michael 1702 "Path to resv database file"
104     },
105     {
106 adx 30 "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 michael 1754 "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 adx 30 "use_logging",
143     OUTPUT_BOOLEAN_YN,
144     &ConfigLoggingEntry.use_logging,
145     "Enable logging"
146     },
147     {
148 michael 1767 "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 adx 30 "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 michael 1432 "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 adx 30 "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 michael 1854 "hide_services",
233     OUTPUT_BOOLEAN_YN,
234     &ConfigServerHide.hide_services,
235     "Hides the location of services server"
236     },
237     {
238 adx 30 "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 michael 1936 "Prevent people from seeing server IP addresses"
248 adx 30 },
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 michael 1936 "Hide spoofed IP addresses"
278 adx 30 },
279     {
280     "ignore_bogus_ts",
281     OUTPUT_BOOLEAN_YN,
282     &ConfigFileEntry.ignore_bogus_ts,
283     "Ignore bogus timestamps from other servers"
284     },
285     {
286     "disable_auth",
287     OUTPUT_BOOLEAN_YN,
288     &ConfigFileEntry.disable_auth,
289     "Completely disable ident lookups"
290     },
291     {
292     "disable_remote_commands",
293     OUTPUT_BOOLEAN_YN,
294     &ConfigFileEntry.disable_remote,
295     "Prevent users issuing commands on remote servers"
296     },
297     {
298     "tkline_expire_notices",
299     OUTPUT_BOOLEAN_YN,
300     &ConfigFileEntry.tkline_expire_notices,
301     "Show temporary kline/xline expire notices"
302     },
303     {
304     "default_floodcount",
305     OUTPUT_DECIMAL,
306     &ConfigFileEntry.default_floodcount,
307     "Startup value of FLOODCOUNT"
308     },
309     {
310     "failed_oper_notice",
311     OUTPUT_BOOLEAN,
312     &ConfigFileEntry.failed_oper_notice,
313 michael 1702 "Inform opers if someone tries to /oper with the wrong password"
314 adx 30 },
315     {
316     "dots_in_ident",
317     OUTPUT_DECIMAL,
318     &ConfigFileEntry.dots_in_ident,
319     "Number of permissable dots in an ident"
320     },
321     {
322     "min_nonwildcard",
323     OUTPUT_DECIMAL,
324     &ConfigFileEntry.min_nonwildcard,
325     "Minimum non-wildcard chars in K/G lines"
326     },
327     {
328     "min_nonwildcard_simple",
329     OUTPUT_DECIMAL,
330     &ConfigFileEntry.min_nonwildcard_simple,
331     "Minimum non-wildcards in gecos bans"
332     },
333     {
334     "max_accept",
335     OUTPUT_DECIMAL,
336     &ConfigFileEntry.max_accept,
337     "Maximum nicknames on accept list"
338     },
339     {
340     "anti_nick_flood",
341     OUTPUT_BOOLEAN,
342     &ConfigFileEntry.anti_nick_flood,
343     "NICK flood protection"
344     },
345     {
346     "max_nick_time",
347     OUTPUT_DECIMAL,
348     &ConfigFileEntry.max_nick_time,
349     "NICK flood protection time interval"
350     },
351     {
352     "max_nick_changes",
353     OUTPUT_DECIMAL,
354     &ConfigFileEntry.max_nick_changes,
355     "NICK change threshhold setting"
356     },
357     {
358     "anti_spam_exit_message_time",
359     OUTPUT_DECIMAL,
360     &ConfigFileEntry.anti_spam_exit_message_time,
361     "Duration a client must be connected for to have an exit message"
362     },
363     {
364     "ts_warn_delta",
365     OUTPUT_DECIMAL,
366     &ConfigFileEntry.ts_warn_delta,
367     "Maximum permitted TS delta before displaying a warning"
368     },
369     {
370     "ts_max_delta",
371     OUTPUT_DECIMAL,
372     &ConfigFileEntry.ts_max_delta,
373     "Maximum permitted TS delta from another server"
374     },
375     {
376     "warn_no_nline",
377     OUTPUT_BOOLEAN,
378     &ConfigFileEntry.warn_no_nline,
379     "Display warning if connecting server lacks N-line"
380     },
381     {
382 michael 1767 "stats_e_disabled",
383     OUTPUT_BOOLEAN_YN,
384     &ConfigFileEntry.stats_e_disabled,
385     "Whether or not STATS e is disabled"
386     },
387     {
388 adx 30 "stats_o_oper_only",
389     OUTPUT_BOOLEAN_YN,
390     &ConfigFileEntry.stats_o_oper_only,
391     "STATS O output is only shown to operators"
392     },
393     {
394     "stats_P_oper_only",
395     OUTPUT_BOOLEAN_YN,
396     &ConfigFileEntry.stats_P_oper_only,
397     "STATS P is only shown to operators"
398     },
399     {
400     "stats_i_oper_only",
401     OUTPUT_BOOLEAN2,
402     &ConfigFileEntry.stats_i_oper_only,
403     "STATS I output is only shown to operators"
404     },
405     {
406     "stats_k_oper_only",
407     OUTPUT_BOOLEAN2,
408     &ConfigFileEntry.stats_k_oper_only,
409     "STATS K output is only shown to operators"
410     },
411     {
412     "caller_id_wait",
413     OUTPUT_DECIMAL,
414     &ConfigFileEntry.caller_id_wait,
415     "Minimum delay between notifying UMODE +g users of messages"
416     },
417     {
418     "opers_bypass_callerid",
419     OUTPUT_BOOLEAN_YN,
420     &ConfigFileEntry.opers_bypass_callerid,
421     "Allows IRC operators to message users who are +g (callerid)"
422     },
423     {
424     "pace_wait_simple",
425     OUTPUT_DECIMAL,
426     &ConfigFileEntry.pace_wait_simple,
427     "Minimum delay between less intensive commands"
428     },
429     {
430     "pace_wait",
431     OUTPUT_DECIMAL,
432     &ConfigFileEntry.pace_wait,
433     "Minimum delay between uses of certain commands"
434     },
435     {
436     "short_motd",
437     OUTPUT_BOOLEAN_YN,
438     &ConfigFileEntry.short_motd,
439     "Do not show MOTD; only tell clients they should read it"
440     },
441     {
442     "ping_cookie",
443     OUTPUT_BOOLEAN,
444     &ConfigFileEntry.ping_cookie,
445     "Require ping cookies to connect"
446     },
447     {
448     "no_oper_flood",
449     OUTPUT_BOOLEAN,
450     &ConfigFileEntry.no_oper_flood,
451     "Reduce flood control for operators"
452     },
453     {
454     "true_no_oper_flood",
455     OUTPUT_BOOLEAN,
456     &ConfigFileEntry.true_no_oper_flood,
457     "Completely disable flood control for operators"
458     },
459     {
460     "oper_pass_resv",
461     OUTPUT_BOOLEAN_YN,
462     &ConfigFileEntry.oper_pass_resv,
463     "Opers can over-ride RESVs"
464     },
465     {
466     "max_targets",
467     OUTPUT_DECIMAL,
468     &ConfigFileEntry.max_targets,
469     "The maximum number of PRIVMSG/NOTICE targets"
470     },
471     {
472     "throttle_time",
473     OUTPUT_DECIMAL,
474     &ConfigFileEntry.throttle_time,
475     "Minimum time between client reconnects"
476     },
477     {
478     "glines",
479     OUTPUT_BOOLEAN,
480     &ConfigFileEntry.glines,
481     "G-line (network-wide K-line) support"
482     },
483     {
484 michael 1459 "gline_duration",
485 adx 30 OUTPUT_DECIMAL,
486     &ConfigFileEntry.gline_time,
487     "Expiry time for G-lines"
488     },
489 michael 1459 {
490     "gline_request_duration",
491     OUTPUT_DECIMAL,
492     &ConfigFileEntry.gline_request_time,
493     "Expiry time for pending G-lines"
494     },
495    
496 adx 30 /* --[ END OF TABLE ]---------------------------------------------- */
497     {
498     NULL,
499     0,
500     NULL,
501     0
502     }
503     };
504    
505     /* send_birthdate_online_time()
506     *
507     * inputs - client pointer to send to
508     * output - NONE
509     * side effects - birthdate and online time are sent
510     */
511     static void
512     send_birthdate_online_time(struct Client *source_p)
513     {
514     if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
515     sendto_one(source_p, ":%s %d %s :On-line since %s",
516     me.id, RPL_INFO, source_p->id,
517 michael 1241 myctime(me.localClient->firsttime));
518 adx 30 else
519     sendto_one(source_p, ":%s %d %s :On-line since %s",
520     me.name, RPL_INFO, source_p->name,
521 michael 1241 myctime(me.localClient->firsttime));
522 adx 30 }
523    
524     /* send_conf_options()
525     *
526     * inputs - client pointer to send to
527     * output - NONE
528     * side effects - send config options to client
529     */
530     static void
531     send_conf_options(struct Client *source_p)
532     {
533     const char *from, *to;
534     const struct InfoStruct *iptr = NULL;
535    
536     /* Now send them a list of all our configuration options
537 michael 912 * (mostly from defaults.h and config.h)
538 adx 30 */
539     if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
540     {
541     from = me.id;
542     to = source_p->id;
543     }
544     else
545     {
546     from = me.name;
547     to = source_p->name;
548     }
549    
550     /*
551     * Parse the info_table[] and do the magic.
552     */
553     for (iptr = info_table; iptr->name; ++iptr)
554     {
555     switch (iptr->output_type)
556     {
557     /* For "char *" references */
558     case OUTPUT_STRING:
559     {
560     const char *option = *((char **)iptr->option);
561    
562     sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
563     from, RPL_INFO, to,
564     iptr->name, option ? option : "NONE",
565     iptr->desc ? iptr->desc : "<none>");
566     break;
567     }
568    
569     /* For "char foo[]" references */
570     case OUTPUT_STRING_PTR:
571     {
572     const char *option = iptr->option;
573    
574     sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
575     from, RPL_INFO, to,
576     iptr->name, option ? option : "NONE",
577     iptr->desc ? iptr->desc : "<none>");
578     break;
579     }
580    
581     /* Output info_table[i].option as a decimal value. */
582     case OUTPUT_DECIMAL:
583     {
584     const int option = *((int *)iptr->option);
585    
586     sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]",
587     from, RPL_INFO, to, iptr->name,
588     option, iptr->desc ? iptr->desc : "<none>");
589     break;
590     }
591    
592     /* Output info_table[i].option as "ON" or "OFF" */
593     case OUTPUT_BOOLEAN:
594     {
595     const int option = *((int *)iptr->option);
596    
597     sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
598     from, RPL_INFO, to,
599     iptr->name, option ? "ON" : "OFF",
600     iptr->desc ? iptr->desc : "<none>");
601    
602     break;
603     }
604    
605     /* Output info_table[i].option as "YES" or "NO" */
606     case OUTPUT_BOOLEAN_YN:
607     {
608 michael 1827 const int option = *((int *)iptr->option);
609 adx 30
610     sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
611     from, RPL_INFO, to,
612     iptr->name, option ? "YES" : "NO",
613     iptr->desc ? iptr->desc : "<none>");
614     break;
615     }
616    
617     case OUTPUT_BOOLEAN2:
618     {
619 michael 1827 const int option = *((int *)iptr->option);
620 adx 30
621     sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]",
622     from, RPL_INFO, to,
623     iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO",
624     iptr->desc ? iptr->desc : "<none>");
625     break;
626     }
627     }
628     }
629    
630 michael 1834 sendto_one(source_p, form_str(RPL_INFO),
631 adx 30 from, to, "");
632     }
633 michael 1230
634 michael 1827 /* send_info_text()
635     *
636     * inputs - client pointer to send info text to
637     * output - NONE
638     * side effects - info text is sent to client
639     */
640     static void
641     send_info_text(struct Client *source_p)
642     {
643     const char **text = infotext;
644     char *source, *target;
645    
646     sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
647     "INFO requested by %s (%s@%s) [%s]",
648     source_p->name, source_p->username,
649     source_p->host, source_p->servptr->name);
650    
651     if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) &&
652     HasID(source_p))
653     source = me.id, target = source_p->id;
654     else
655     source = me.name, target = source_p->name;
656    
657     while (*text)
658     {
659     const char *line = *text++;
660    
661     if (*line == '\0')
662     line = " ";
663    
664 michael 1834 sendto_one(source_p, form_str(RPL_INFO),
665 michael 1827 source, target, line);
666     }
667    
668     if (HasUMode(source_p, UMODE_OPER))
669     send_conf_options(source_p);
670    
671     send_birthdate_online_time(source_p);
672    
673 michael 1834 sendto_one(source_p, form_str(RPL_ENDOFINFO),
674 michael 1827 me.name, source_p->name);
675     }
676    
677     /*
678     ** m_info()
679     ** parv[0] = sender prefix
680     ** parv[1] = servername
681     */
682     static void
683     m_info(struct Client *client_p, struct Client *source_p,
684     int parc, char *parv[])
685     {
686     static time_t last_used = 0;
687    
688     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
689     {
690     /* safe enough to give this on a local connect only */
691 michael 1834 sendto_one(source_p, form_str(RPL_LOAD2HI),
692 michael 1827 me.name, source_p->name);
693     return;
694     }
695    
696     last_used = CurrentTime;
697    
698     if (!ConfigFileEntry.disable_remote)
699     if (hunt_server(client_p,source_p, ":%s INFO :%s", 1,
700     parc, parv) != HUNTED_ISME)
701     return;
702    
703     send_info_text(source_p);
704     }
705    
706     /*
707     ** ms_info()
708     ** parv[0] = sender prefix
709     ** parv[1] = servername
710     */
711     static void
712     ms_info(struct Client *client_p, struct Client *source_p,
713     int parc, char *parv[])
714     {
715     if (!IsClient(source_p))
716     return;
717    
718     if (hunt_server(client_p, source_p, ":%s INFO :%s", 1,
719     parc, parv) != HUNTED_ISME)
720     return;
721    
722     send_info_text(source_p);
723     }
724    
725 michael 1230 static struct Message info_msgtab = {
726     "INFO", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
727 michael 1827 { m_unregistered, m_info, ms_info, m_ignore, ms_info, m_ignore }
728 michael 1230 };
729    
730     static void
731     module_init(void)
732     {
733     mod_add_cmd(&info_msgtab);
734     }
735    
736     static void
737     module_exit(void)
738     {
739     mod_del_cmd(&info_msgtab);
740     }
741    
742     struct module module_entry = {
743     .node = { NULL, NULL, NULL },
744     .name = NULL,
745     .version = "$Revision$",
746     .handle = NULL,
747     .modinit = module_init,
748     .modexit = module_exit,
749     .flags = 0
750     };

Properties

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