ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_info.c
Revision: 1549
Committed: Mon Oct 1 18:11:11 2012 UTC (14 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_info.c
File size: 17556 byte(s)
Log Message:
- Removed general::kline_with_reason configuration options. It's now enabled
  by default
- Removed remnants of the broken reject holding code

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

Properties

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