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