1 |
/* |
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 |
* $Id$ |
23 |
*/ |
24 |
|
25 |
#include "stdinc.h" |
26 |
#include "list.h" |
27 |
#include "m_info.h" |
28 |
#include "channel.h" |
29 |
#include "client.h" |
30 |
#include "common.h" |
31 |
#include "irc_string.h" |
32 |
#include "ircd.h" |
33 |
#include "hook.h" |
34 |
#include "numeric.h" |
35 |
#include "s_log.h" |
36 |
#include "s_serv.h" |
37 |
#include "s_user.h" |
38 |
#include "send.h" |
39 |
#include "s_conf.h" |
40 |
#include "handlers.h" |
41 |
#include "msg.h" |
42 |
#include "parse.h" |
43 |
#include "modules.h" |
44 |
|
45 |
static void send_conf_options(struct Client *); |
46 |
static void send_birthdate_online_time(struct Client *); |
47 |
static void send_info_text(struct Client *); |
48 |
|
49 |
static void m_info(struct Client *, struct Client *, int, char *[]); |
50 |
static void ms_info(struct Client *, struct Client *, int, char *[]); |
51 |
static void mo_info(struct Client *, struct Client *, int, char *[]); |
52 |
|
53 |
struct Message info_msgtab = { |
54 |
"INFO", 0, 0, 0, 0, MFLG_SLOW, 0, |
55 |
{ m_unregistered, m_info, ms_info, m_ignore, mo_info, m_ignore } |
56 |
}; |
57 |
|
58 |
#ifndef STATIC_MODULES |
59 |
const char *_version = "$Revision$"; |
60 |
static struct Callback *info_cb; |
61 |
|
62 |
static void * |
63 |
va_send_info_text(va_list args) |
64 |
{ |
65 |
send_info_text(va_arg(args, struct Client *)); |
66 |
return NULL; |
67 |
} |
68 |
|
69 |
void |
70 |
_modinit(void) |
71 |
{ |
72 |
info_cb = register_callback("doing_info", va_send_info_text); |
73 |
mod_add_cmd(&info_msgtab); |
74 |
} |
75 |
|
76 |
void |
77 |
_moddeinit(void) |
78 |
{ |
79 |
mod_del_cmd(&info_msgtab); |
80 |
uninstall_hook(info_cb, va_send_info_text); |
81 |
} |
82 |
#endif |
83 |
|
84 |
/* |
85 |
* jdc -- Structure for our configuration value table |
86 |
*/ |
87 |
struct InfoStruct |
88 |
{ |
89 |
const char *name; /* Displayed variable name */ |
90 |
unsigned int output_type; /* See below #defines */ |
91 |
void *option; /* Pointer reference to the value */ |
92 |
const char *desc; /* ASCII description of the variable */ |
93 |
}; |
94 |
|
95 |
/* Types for output_type in InfoStruct */ |
96 |
#define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */ |
97 |
#define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */ |
98 |
#define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */ |
99 |
#define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */ |
100 |
#define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */ |
101 |
#define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */ |
102 |
|
103 |
static const struct InfoStruct info_table[] = |
104 |
{ |
105 |
/* --[ START OF TABLE ]-------------------------------------------- */ |
106 |
{ |
107 |
"network_name", |
108 |
OUTPUT_STRING, |
109 |
&ServerInfo.network_name, |
110 |
"Network name" |
111 |
}, |
112 |
{ |
113 |
"network_desc", |
114 |
OUTPUT_STRING, |
115 |
&ServerInfo.network_desc, |
116 |
"Network description" |
117 |
}, |
118 |
{ |
119 |
"hub", |
120 |
OUTPUT_BOOLEAN_YN, |
121 |
&ServerInfo.hub, |
122 |
"Server is a hub" |
123 |
}, |
124 |
{ |
125 |
"use_logging", |
126 |
OUTPUT_BOOLEAN_YN, |
127 |
&ConfigLoggingEntry.use_logging, |
128 |
"Enable logging" |
129 |
}, |
130 |
{ |
131 |
"fuserlog", |
132 |
OUTPUT_STRING_PTR, |
133 |
&ConfigLoggingEntry.userlog, |
134 |
"User log file" |
135 |
}, |
136 |
{ |
137 |
"foperlog", |
138 |
OUTPUT_STRING_PTR, |
139 |
&ConfigLoggingEntry.operlog, |
140 |
"Operator log file" |
141 |
}, |
142 |
{ |
143 |
"fkilllog", |
144 |
OUTPUT_STRING_PTR, |
145 |
&ConfigLoggingEntry.killlog, |
146 |
"Kill log file" |
147 |
}, |
148 |
{ |
149 |
"fklinelog", |
150 |
OUTPUT_STRING_PTR, |
151 |
&ConfigLoggingEntry.klinelog, |
152 |
"K-Line log file" |
153 |
}, |
154 |
{ |
155 |
"fglinelog", |
156 |
OUTPUT_STRING_PTR, |
157 |
&ConfigLoggingEntry.glinelog, |
158 |
"G-Line log file" |
159 |
}, |
160 |
{ |
161 |
"restrict_channels", |
162 |
OUTPUT_BOOLEAN_YN, |
163 |
&ConfigChannel.restrict_channels, |
164 |
"Only reserved channels are allowed" |
165 |
}, |
166 |
{ |
167 |
"disable_local_channels", |
168 |
OUTPUT_BOOLEAN_YN, |
169 |
&ConfigChannel.disable_local_channels, |
170 |
"Prevent users from joining &channels" |
171 |
}, |
172 |
{ |
173 |
"use_invex", |
174 |
OUTPUT_BOOLEAN_YN, |
175 |
&ConfigChannel.use_invex, |
176 |
"Enable chanmode +I (invite exceptions)" |
177 |
}, |
178 |
{ |
179 |
"use_except", |
180 |
OUTPUT_BOOLEAN_YN, |
181 |
&ConfigChannel.use_except, |
182 |
"Enable chanmode +e (ban exceptions)" |
183 |
}, |
184 |
{ |
185 |
"use_knock", |
186 |
OUTPUT_BOOLEAN_YN, |
187 |
&ConfigChannel.use_knock, |
188 |
"Enable /KNOCK" |
189 |
}, |
190 |
{ |
191 |
"knock_delay", |
192 |
OUTPUT_DECIMAL, |
193 |
&ConfigChannel.knock_delay, |
194 |
"Delay between a users KNOCK attempts" |
195 |
}, |
196 |
{ |
197 |
"knock_delay_channel", |
198 |
OUTPUT_DECIMAL, |
199 |
&ConfigChannel.knock_delay_channel, |
200 |
"Delay between KNOCK attempts to a channel" |
201 |
}, |
202 |
{ |
203 |
"max_chans_per_user", |
204 |
OUTPUT_DECIMAL, |
205 |
&ConfigChannel.max_chans_per_user, |
206 |
"Maximum number of channels a user can join" |
207 |
}, |
208 |
{ |
209 |
"quiet_on_ban", |
210 |
OUTPUT_BOOLEAN_YN, |
211 |
&ConfigChannel.quiet_on_ban, |
212 |
"Banned users may not send text to a channel" |
213 |
}, |
214 |
{ |
215 |
"max_bans", |
216 |
OUTPUT_DECIMAL, |
217 |
&ConfigChannel.max_bans, |
218 |
"Total +b/e/I modes allowed in a channel" |
219 |
}, |
220 |
{ |
221 |
"default_split_user_count", |
222 |
OUTPUT_DECIMAL, |
223 |
&ConfigChannel.default_split_user_count, |
224 |
"Startup value of SPLITUSERS" |
225 |
}, |
226 |
{ |
227 |
"default_split_server_count", |
228 |
OUTPUT_DECIMAL, |
229 |
&ConfigChannel.default_split_server_count, |
230 |
"Startup value of SPLITNUM" |
231 |
}, |
232 |
{ |
233 |
"no_create_on_split", |
234 |
OUTPUT_BOOLEAN_YN, |
235 |
&ConfigChannel.no_create_on_split, |
236 |
"Disallow creation of channels when split" |
237 |
}, |
238 |
{ |
239 |
"no_join_on_split", |
240 |
OUTPUT_BOOLEAN_YN, |
241 |
&ConfigChannel.no_join_on_split, |
242 |
"Disallow joining channels when split" |
243 |
}, |
244 |
{ |
245 |
"burst_topicwho", |
246 |
OUTPUT_BOOLEAN_YN, |
247 |
&ConfigChannel.burst_topicwho, |
248 |
"Enable sending of who set topic on topicburst" |
249 |
}, |
250 |
{ |
251 |
"flatten_links", |
252 |
OUTPUT_BOOLEAN_YN, |
253 |
&ConfigServerHide.flatten_links, |
254 |
"Flatten /links list" |
255 |
}, |
256 |
{ |
257 |
"links_delay", |
258 |
OUTPUT_DECIMAL, |
259 |
&ConfigServerHide.links_delay, |
260 |
"Links rehash delay" |
261 |
}, |
262 |
{ |
263 |
"hidden", |
264 |
OUTPUT_BOOLEAN_YN, |
265 |
&ConfigServerHide.hidden, |
266 |
"Hide this server from a flattened /links on remote servers" |
267 |
}, |
268 |
{ |
269 |
"disable_hidden", |
270 |
OUTPUT_BOOLEAN_YN, |
271 |
&ConfigServerHide.disable_hidden, |
272 |
"Prevent servers from hiding themselves from a flattened /links" |
273 |
}, |
274 |
{ |
275 |
"hide_servers", |
276 |
OUTPUT_BOOLEAN_YN, |
277 |
&ConfigServerHide.hide_servers, |
278 |
"Hide servernames from users" |
279 |
}, |
280 |
{ |
281 |
"hidden_name", |
282 |
OUTPUT_STRING, |
283 |
&ConfigServerHide.hidden_name, |
284 |
"Server name users see if hide_servers = yes" |
285 |
}, |
286 |
{ |
287 |
"hide_server_ips", |
288 |
OUTPUT_BOOLEAN_YN, |
289 |
&ConfigServerHide.hide_server_ips, |
290 |
"Prevent people from seeing server IPs" |
291 |
}, |
292 |
{ |
293 |
"gline_min_cidr", |
294 |
OUTPUT_DECIMAL, |
295 |
&ConfigFileEntry.gline_min_cidr, |
296 |
"Minimum required length of a CIDR bitmask for IPv4 G-Lines" |
297 |
}, |
298 |
{ |
299 |
"gline_min_cidr6", |
300 |
OUTPUT_DECIMAL, |
301 |
&ConfigFileEntry.gline_min_cidr6, |
302 |
"Minimum required length of a CIDR bitmask for IPv6 G-Lines" |
303 |
}, |
304 |
{ |
305 |
"invisible_on_connect", |
306 |
OUTPUT_BOOLEAN_YN, |
307 |
&ConfigFileEntry.invisible_on_connect, |
308 |
"Automatically set mode +i on connecting users" |
309 |
}, |
310 |
{ |
311 |
"burst_away", |
312 |
OUTPUT_BOOLEAN_YN, |
313 |
&ConfigFileEntry.burst_away, |
314 |
"Send /away string that users have set on the server burst" |
315 |
}, |
316 |
{ |
317 |
"use_whois_actually", |
318 |
OUTPUT_BOOLEAN_YN, |
319 |
&ConfigFileEntry.use_whois_actually, |
320 |
"Show IP address on /WHOIS when possible" |
321 |
}, |
322 |
{ |
323 |
"kill_chase_time_limit", |
324 |
OUTPUT_DECIMAL, |
325 |
&ConfigFileEntry.kill_chase_time_limit, |
326 |
"Nick Change Tracker for KILL" |
327 |
}, |
328 |
{ |
329 |
"hide_spoof_ips", |
330 |
OUTPUT_BOOLEAN_YN, |
331 |
&ConfigFileEntry.hide_spoof_ips, |
332 |
"Hide spoofed IP's" |
333 |
}, |
334 |
{ |
335 |
"ignore_bogus_ts", |
336 |
OUTPUT_BOOLEAN_YN, |
337 |
&ConfigFileEntry.ignore_bogus_ts, |
338 |
"Ignore bogus timestamps from other servers" |
339 |
}, |
340 |
{ |
341 |
"disable_auth", |
342 |
OUTPUT_BOOLEAN_YN, |
343 |
&ConfigFileEntry.disable_auth, |
344 |
"Completely disable ident lookups" |
345 |
}, |
346 |
{ |
347 |
"disable_remote_commands", |
348 |
OUTPUT_BOOLEAN_YN, |
349 |
&ConfigFileEntry.disable_remote, |
350 |
"Prevent users issuing commands on remote servers" |
351 |
}, |
352 |
{ |
353 |
"tkline_expire_notices", |
354 |
OUTPUT_BOOLEAN_YN, |
355 |
&ConfigFileEntry.tkline_expire_notices, |
356 |
"Show temporary kline/xline expire notices" |
357 |
}, |
358 |
{ |
359 |
"default_floodcount", |
360 |
OUTPUT_DECIMAL, |
361 |
&ConfigFileEntry.default_floodcount, |
362 |
"Startup value of FLOODCOUNT" |
363 |
}, |
364 |
{ |
365 |
"failed_oper_notice", |
366 |
OUTPUT_BOOLEAN, |
367 |
&ConfigFileEntry.failed_oper_notice, |
368 |
"Inform opers if someone /oper's with the wrong password" |
369 |
}, |
370 |
{ |
371 |
"dots_in_ident", |
372 |
OUTPUT_DECIMAL, |
373 |
&ConfigFileEntry.dots_in_ident, |
374 |
"Number of permissable dots in an ident" |
375 |
}, |
376 |
{ |
377 |
"dot_in_ip6_addr", |
378 |
OUTPUT_BOOLEAN, |
379 |
&ConfigFileEntry.dot_in_ip6_addr, |
380 |
"Suffix a . to ip6 addresses (for linked servers still running hybrid-6)" |
381 |
}, |
382 |
{ |
383 |
"min_nonwildcard", |
384 |
OUTPUT_DECIMAL, |
385 |
&ConfigFileEntry.min_nonwildcard, |
386 |
"Minimum non-wildcard chars in K/G lines" |
387 |
}, |
388 |
{ |
389 |
"min_nonwildcard_simple", |
390 |
OUTPUT_DECIMAL, |
391 |
&ConfigFileEntry.min_nonwildcard_simple, |
392 |
"Minimum non-wildcards in gecos bans" |
393 |
}, |
394 |
{ |
395 |
"max_accept", |
396 |
OUTPUT_DECIMAL, |
397 |
&ConfigFileEntry.max_accept, |
398 |
"Maximum nicknames on accept list" |
399 |
}, |
400 |
{ |
401 |
"anti_nick_flood", |
402 |
OUTPUT_BOOLEAN, |
403 |
&ConfigFileEntry.anti_nick_flood, |
404 |
"NICK flood protection" |
405 |
}, |
406 |
{ |
407 |
"max_nick_time", |
408 |
OUTPUT_DECIMAL, |
409 |
&ConfigFileEntry.max_nick_time, |
410 |
"NICK flood protection time interval" |
411 |
}, |
412 |
{ |
413 |
"max_nick_changes", |
414 |
OUTPUT_DECIMAL, |
415 |
&ConfigFileEntry.max_nick_changes, |
416 |
"NICK change threshhold setting" |
417 |
}, |
418 |
{ |
419 |
"anti_spam_exit_message_time", |
420 |
OUTPUT_DECIMAL, |
421 |
&ConfigFileEntry.anti_spam_exit_message_time, |
422 |
"Duration a client must be connected for to have an exit message" |
423 |
}, |
424 |
{ |
425 |
"ts_warn_delta", |
426 |
OUTPUT_DECIMAL, |
427 |
&ConfigFileEntry.ts_warn_delta, |
428 |
"Maximum permitted TS delta before displaying a warning" |
429 |
}, |
430 |
{ |
431 |
"ts_max_delta", |
432 |
OUTPUT_DECIMAL, |
433 |
&ConfigFileEntry.ts_max_delta, |
434 |
"Maximum permitted TS delta from another server" |
435 |
}, |
436 |
{ |
437 |
"kline_with_reason", |
438 |
OUTPUT_BOOLEAN_YN, |
439 |
&ConfigFileEntry.kline_with_reason, |
440 |
"Display K-line reason to client on disconnect" |
441 |
}, |
442 |
{ |
443 |
"kline_reason", |
444 |
OUTPUT_STRING, |
445 |
&ConfigFileEntry.kline_reason, |
446 |
"Reason given to K-lined clients on sign off" |
447 |
}, |
448 |
{ |
449 |
"warn_no_nline", |
450 |
OUTPUT_BOOLEAN, |
451 |
&ConfigFileEntry.warn_no_nline, |
452 |
"Display warning if connecting server lacks N-line" |
453 |
}, |
454 |
{ |
455 |
"stats_o_oper_only", |
456 |
OUTPUT_BOOLEAN_YN, |
457 |
&ConfigFileEntry.stats_o_oper_only, |
458 |
"STATS O output is only shown to operators" |
459 |
}, |
460 |
{ |
461 |
"stats_P_oper_only", |
462 |
OUTPUT_BOOLEAN_YN, |
463 |
&ConfigFileEntry.stats_P_oper_only, |
464 |
"STATS P is only shown to operators" |
465 |
}, |
466 |
{ |
467 |
"stats_i_oper_only", |
468 |
OUTPUT_BOOLEAN2, |
469 |
&ConfigFileEntry.stats_i_oper_only, |
470 |
"STATS I output is only shown to operators" |
471 |
}, |
472 |
{ |
473 |
"stats_k_oper_only", |
474 |
OUTPUT_BOOLEAN2, |
475 |
&ConfigFileEntry.stats_k_oper_only, |
476 |
"STATS K output is only shown to operators" |
477 |
}, |
478 |
{ |
479 |
"caller_id_wait", |
480 |
OUTPUT_DECIMAL, |
481 |
&ConfigFileEntry.caller_id_wait, |
482 |
"Minimum delay between notifying UMODE +g users of messages" |
483 |
}, |
484 |
{ |
485 |
"opers_bypass_callerid", |
486 |
OUTPUT_BOOLEAN_YN, |
487 |
&ConfigFileEntry.opers_bypass_callerid, |
488 |
"Allows IRC operators to message users who are +g (callerid)" |
489 |
}, |
490 |
{ |
491 |
"pace_wait_simple", |
492 |
OUTPUT_DECIMAL, |
493 |
&ConfigFileEntry.pace_wait_simple, |
494 |
"Minimum delay between less intensive commands" |
495 |
}, |
496 |
{ |
497 |
"pace_wait", |
498 |
OUTPUT_DECIMAL, |
499 |
&ConfigFileEntry.pace_wait, |
500 |
"Minimum delay between uses of certain commands" |
501 |
}, |
502 |
{ |
503 |
"short_motd", |
504 |
OUTPUT_BOOLEAN_YN, |
505 |
&ConfigFileEntry.short_motd, |
506 |
"Do not show MOTD; only tell clients they should read it" |
507 |
}, |
508 |
{ |
509 |
"ping_cookie", |
510 |
OUTPUT_BOOLEAN, |
511 |
&ConfigFileEntry.ping_cookie, |
512 |
"Require ping cookies to connect" |
513 |
}, |
514 |
{ |
515 |
"no_oper_flood", |
516 |
OUTPUT_BOOLEAN, |
517 |
&ConfigFileEntry.no_oper_flood, |
518 |
"Reduce flood control for operators" |
519 |
}, |
520 |
{ |
521 |
"true_no_oper_flood", |
522 |
OUTPUT_BOOLEAN, |
523 |
&ConfigFileEntry.true_no_oper_flood, |
524 |
"Completely disable flood control for operators" |
525 |
}, |
526 |
{ |
527 |
"oper_pass_resv", |
528 |
OUTPUT_BOOLEAN_YN, |
529 |
&ConfigFileEntry.oper_pass_resv, |
530 |
"Opers can over-ride RESVs" |
531 |
}, |
532 |
{ |
533 |
"idletime", |
534 |
OUTPUT_DECIMAL, |
535 |
&ConfigFileEntry.idletime, |
536 |
"Number of seconds before a client is considered idle" |
537 |
}, |
538 |
{ |
539 |
"max_targets", |
540 |
OUTPUT_DECIMAL, |
541 |
&ConfigFileEntry.max_targets, |
542 |
"The maximum number of PRIVMSG/NOTICE targets" |
543 |
}, |
544 |
{ |
545 |
"client_flood", |
546 |
OUTPUT_DECIMAL, |
547 |
&ConfigFileEntry.client_flood, |
548 |
"Maximum amount of data in a client's queue before they are disconnected" |
549 |
}, |
550 |
{ |
551 |
"throttle_time", |
552 |
OUTPUT_DECIMAL, |
553 |
&ConfigFileEntry.throttle_time, |
554 |
"Minimum time between client reconnects" |
555 |
}, |
556 |
{ |
557 |
"glines", |
558 |
OUTPUT_BOOLEAN, |
559 |
&ConfigFileEntry.glines, |
560 |
"G-line (network-wide K-line) support" |
561 |
}, |
562 |
{ |
563 |
"duration", |
564 |
OUTPUT_DECIMAL, |
565 |
&ConfigFileEntry.gline_time, |
566 |
"Expiry time for G-lines" |
567 |
}, |
568 |
/* --[ END OF TABLE ]---------------------------------------------- */ |
569 |
{ |
570 |
NULL, |
571 |
0, |
572 |
NULL, |
573 |
0 |
574 |
} |
575 |
}; |
576 |
|
577 |
/* |
578 |
** m_info() |
579 |
** parv[0] = sender prefix |
580 |
** parv[1] = servername |
581 |
*/ |
582 |
static void |
583 |
m_info(struct Client *client_p, struct Client *source_p, |
584 |
int parc, char *parv[]) |
585 |
{ |
586 |
static time_t last_used = 0; |
587 |
|
588 |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
589 |
{ |
590 |
/* safe enough to give this on a local connect only */ |
591 |
sendto_one(source_p, form_str(RPL_LOAD2HI), |
592 |
me.name, source_p->name); |
593 |
return; |
594 |
} |
595 |
else |
596 |
last_used = CurrentTime; |
597 |
|
598 |
if (!ConfigFileEntry.disable_remote) |
599 |
{ |
600 |
if (hunt_server(client_p,source_p, ":%s INFO :%s", |
601 |
1, parc, parv) != HUNTED_ISME) |
602 |
{ |
603 |
return; |
604 |
} |
605 |
} |
606 |
|
607 |
#ifdef STATIC_MODULES |
608 |
send_info_text(source_p); |
609 |
#else |
610 |
execute_callback(info_cb, source_p, parc, parv); |
611 |
#endif |
612 |
} |
613 |
|
614 |
/* |
615 |
** mo_info() |
616 |
** parv[0] = sender prefix |
617 |
** parv[1] = servername |
618 |
*/ |
619 |
static void |
620 |
mo_info(struct Client *client_p, struct Client *source_p, |
621 |
int parc, char *parv[]) |
622 |
{ |
623 |
if (hunt_server(client_p, source_p, ":%s INFO :%s", 1, |
624 |
parc, parv) != HUNTED_ISME) |
625 |
return; |
626 |
|
627 |
#ifdef STATIC_MODULES |
628 |
send_info_text(source_p); |
629 |
#else |
630 |
execute_callback(info_cb, source_p, parc, parv); |
631 |
#endif |
632 |
} |
633 |
|
634 |
/* |
635 |
** ms_info() |
636 |
** parv[0] = sender prefix |
637 |
** parv[1] = servername |
638 |
*/ |
639 |
static void |
640 |
ms_info(struct Client *client_p, struct Client *source_p, |
641 |
int parc, char *parv[]) |
642 |
{ |
643 |
if (!IsClient(source_p)) |
644 |
return; |
645 |
|
646 |
if (hunt_server(client_p, source_p, ":%s INFO :%s", |
647 |
1, parc, parv) != HUNTED_ISME) |
648 |
return; |
649 |
|
650 |
#ifdef STATIC_MODULES |
651 |
send_info_text(source_p); |
652 |
#else |
653 |
execute_callback(info_cb, source_p, parc, parv); |
654 |
#endif |
655 |
} |
656 |
|
657 |
/* send_info_text() |
658 |
* |
659 |
* inputs - client pointer to send info text to |
660 |
* output - NONE |
661 |
* side effects - info text is sent to client |
662 |
*/ |
663 |
static void |
664 |
send_info_text(struct Client *source_p) |
665 |
{ |
666 |
const char **text = infotext; |
667 |
char *source, *target; |
668 |
|
669 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && |
670 |
HasID(source_p)) |
671 |
source = me.id, target = source_p->id; |
672 |
else |
673 |
source = me.name, target = source_p->name; |
674 |
|
675 |
while (*text) |
676 |
{ |
677 |
const char *line = *text++; |
678 |
|
679 |
if (*line == '\0') |
680 |
line = " "; |
681 |
|
682 |
sendto_one(source_p, form_str(RPL_INFO), |
683 |
source, target, line); |
684 |
} |
685 |
|
686 |
if (IsOper(source_p)) |
687 |
send_conf_options(source_p); |
688 |
|
689 |
send_birthdate_online_time(source_p); |
690 |
|
691 |
sendto_one(source_p, form_str(RPL_ENDOFINFO), |
692 |
me.name, source_p->name); |
693 |
} |
694 |
|
695 |
/* send_birthdate_online_time() |
696 |
* |
697 |
* inputs - client pointer to send to |
698 |
* output - NONE |
699 |
* side effects - birthdate and online time are sent |
700 |
*/ |
701 |
static void |
702 |
send_birthdate_online_time(struct Client *source_p) |
703 |
{ |
704 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
705 |
{ |
706 |
sendto_one(source_p, ":%s %d %s :On-line since %s", |
707 |
me.id, RPL_INFO, source_p->id, |
708 |
myctime(me.firsttime)); |
709 |
} |
710 |
else |
711 |
{ |
712 |
sendto_one(source_p, ":%s %d %s :On-line since %s", |
713 |
me.name, RPL_INFO, source_p->name, |
714 |
myctime(me.firsttime)); |
715 |
} |
716 |
} |
717 |
|
718 |
/* send_conf_options() |
719 |
* |
720 |
* inputs - client pointer to send to |
721 |
* output - NONE |
722 |
* side effects - send config options to client |
723 |
*/ |
724 |
static void |
725 |
send_conf_options(struct Client *source_p) |
726 |
{ |
727 |
Info *infoptr; |
728 |
const char *from, *to; |
729 |
const struct InfoStruct *iptr = NULL; |
730 |
|
731 |
/* Now send them a list of all our configuration options |
732 |
* (mostly from defaults.h and config.h) |
733 |
*/ |
734 |
if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
735 |
{ |
736 |
from = me.id; |
737 |
to = source_p->id; |
738 |
} |
739 |
else |
740 |
{ |
741 |
from = me.name; |
742 |
to = source_p->name; |
743 |
} |
744 |
|
745 |
for (infoptr = MyInformation; infoptr->name; infoptr++) |
746 |
{ |
747 |
if (infoptr->intvalue) |
748 |
{ |
749 |
sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]", |
750 |
from, RPL_INFO, to, infoptr->name, |
751 |
infoptr->intvalue, infoptr->desc); |
752 |
} |
753 |
else |
754 |
{ |
755 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
756 |
from, RPL_INFO, to, infoptr->name, |
757 |
infoptr->strvalue, infoptr->desc); |
758 |
} |
759 |
} |
760 |
|
761 |
/* |
762 |
* Parse the info_table[] and do the magic. |
763 |
*/ |
764 |
for (iptr = info_table; iptr->name; ++iptr) |
765 |
{ |
766 |
switch (iptr->output_type) |
767 |
{ |
768 |
/* For "char *" references */ |
769 |
case OUTPUT_STRING: |
770 |
{ |
771 |
const char *option = *((char **)iptr->option); |
772 |
|
773 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
774 |
from, RPL_INFO, to, |
775 |
iptr->name, option ? option : "NONE", |
776 |
iptr->desc ? iptr->desc : "<none>"); |
777 |
break; |
778 |
} |
779 |
|
780 |
/* For "char foo[]" references */ |
781 |
case OUTPUT_STRING_PTR: |
782 |
{ |
783 |
const char *option = iptr->option; |
784 |
|
785 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
786 |
from, RPL_INFO, to, |
787 |
iptr->name, option ? option : "NONE", |
788 |
iptr->desc ? iptr->desc : "<none>"); |
789 |
break; |
790 |
} |
791 |
|
792 |
/* Output info_table[i].option as a decimal value. */ |
793 |
case OUTPUT_DECIMAL: |
794 |
{ |
795 |
const int option = *((int *)iptr->option); |
796 |
|
797 |
sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]", |
798 |
from, RPL_INFO, to, iptr->name, |
799 |
option, iptr->desc ? iptr->desc : "<none>"); |
800 |
break; |
801 |
} |
802 |
|
803 |
/* Output info_table[i].option as "ON" or "OFF" */ |
804 |
case OUTPUT_BOOLEAN: |
805 |
{ |
806 |
const int option = *((int *)iptr->option); |
807 |
|
808 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
809 |
from, RPL_INFO, to, |
810 |
iptr->name, option ? "ON" : "OFF", |
811 |
iptr->desc ? iptr->desc : "<none>"); |
812 |
|
813 |
break; |
814 |
} |
815 |
|
816 |
/* Output info_table[i].option as "YES" or "NO" */ |
817 |
case OUTPUT_BOOLEAN_YN: |
818 |
{ |
819 |
int option = *((int *)iptr->option); |
820 |
|
821 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
822 |
from, RPL_INFO, to, |
823 |
iptr->name, option ? "YES" : "NO", |
824 |
iptr->desc ? iptr->desc : "<none>"); |
825 |
break; |
826 |
} |
827 |
|
828 |
case OUTPUT_BOOLEAN2: |
829 |
{ |
830 |
int option = *((int *)iptr->option); |
831 |
|
832 |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
833 |
from, RPL_INFO, to, |
834 |
iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO", |
835 |
iptr->desc ? iptr->desc : "<none>"); |
836 |
break; |
837 |
} |
838 |
} |
839 |
} |
840 |
|
841 |
/* Don't send oper_only_umodes...it's a bit mask, we will have to decode it |
842 |
* in order for it to show up properly to opers who issue INFO |
843 |
*/ |
844 |
#ifndef EFNET |
845 |
/* jdc -- Only send compile information to admins. */ |
846 |
if (IsAdmin(source_p)) |
847 |
sendto_one(source_p, ":%s %d %s :Running on [%s]", |
848 |
from, RPL_INFO, to, ircd_platform); |
849 |
#endif |
850 |
sendto_one(source_p, form_str(RPL_INFO), |
851 |
from, to, ""); |
852 |
} |