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