1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2015 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_info.c |
23 |
* \brief Includes required functions for processing the INFO command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "client.h" |
30 |
#include "ircd.h" |
31 |
#include "numeric.h" |
32 |
#include "misc.h" |
33 |
#include "server.h" |
34 |
#include "send.h" |
35 |
#include "conf.h" |
36 |
#include "parse.h" |
37 |
#include "modules.h" |
38 |
|
39 |
|
40 |
/* Types for output_type in InfoStruct */ |
41 |
enum |
42 |
{ |
43 |
OUTPUT_STRING = 1 << 0, /* Output option as %s w/ dereference */ |
44 |
OUTPUT_STRING_PTR = 1 << 1, /* Output option as %s w/out deference */ |
45 |
OUTPUT_DECIMAL = 1 << 2, /* Output option as decimal (%d) */ |
46 |
OUTPUT_BOOLEAN = 1 << 3, /* Output option as "ON" or "OFF" */ |
47 |
OUTPUT_BOOLEAN_YN = 1 << 4, /* Output option as "YES" or "NO" */ |
48 |
OUTPUT_BOOLEAN2 = 1 << 5 /* Output option as "YES/NO/MASKED" */ |
49 |
}; |
50 |
|
51 |
/* |
52 |
* jdc -- Structure for our configuration value table |
53 |
*/ |
54 |
struct InfoStruct |
55 |
{ |
56 |
const char *name; /* Displayed variable name */ |
57 |
const unsigned int output_type; /* Type of output. See enum above */ |
58 |
const void *option; /* Pointer reference to the value */ |
59 |
const char *desc; /* ASCII description of the variable */ |
60 |
}; |
61 |
|
62 |
static const struct InfoStruct info_table[] = |
63 |
{ |
64 |
/* --[ START OF TABLE ]-------------------------------------------- */ |
65 |
|
66 |
{ |
67 |
"DPATH", |
68 |
OUTPUT_STRING, |
69 |
&ConfigGeneral.dpath, |
70 |
"Root directory of installation" |
71 |
}, |
72 |
{ |
73 |
"SPATH", |
74 |
OUTPUT_STRING, |
75 |
&ConfigGeneral.spath, |
76 |
"Path to server executable" |
77 |
}, |
78 |
{ |
79 |
"MPATH", |
80 |
OUTPUT_STRING, |
81 |
&ConfigGeneral.mpath, |
82 |
"Path to main motd (Message of the Day) file" |
83 |
}, |
84 |
{ |
85 |
"CPATH", |
86 |
OUTPUT_STRING, |
87 |
&ConfigGeneral.configfile, |
88 |
"Path to main configuration file" |
89 |
}, |
90 |
{ |
91 |
"DLPATH", |
92 |
OUTPUT_STRING, |
93 |
&ConfigGeneral.dlinefile, |
94 |
"Path to D-line database file" |
95 |
}, |
96 |
{ |
97 |
"KPATH", |
98 |
OUTPUT_STRING, |
99 |
&ConfigGeneral.klinefile, |
100 |
"Path to K-line database file" |
101 |
}, |
102 |
{ |
103 |
"XPATH", |
104 |
OUTPUT_STRING, |
105 |
&ConfigGeneral.xlinefile, |
106 |
"Path to X-line database file" |
107 |
}, |
108 |
{ |
109 |
"RESVPATH", |
110 |
OUTPUT_STRING, |
111 |
&ConfigGeneral.resvfile, |
112 |
"Path to resv database file" |
113 |
}, |
114 |
{ |
115 |
"network_name", |
116 |
OUTPUT_STRING, |
117 |
&ConfigServerInfo.network_name, |
118 |
"Network name" |
119 |
}, |
120 |
{ |
121 |
"network_desc", |
122 |
OUTPUT_STRING, |
123 |
&ConfigServerInfo.network_desc, |
124 |
"Network description" |
125 |
}, |
126 |
{ |
127 |
"hub", |
128 |
OUTPUT_BOOLEAN_YN, |
129 |
&ConfigServerInfo.hub, |
130 |
"Server is a hub" |
131 |
}, |
132 |
{ |
133 |
"default_max_clients", |
134 |
OUTPUT_DECIMAL, |
135 |
&ConfigServerInfo.default_max_clients, |
136 |
"The default maximum number of clients permitted simultaneously on this server" |
137 |
}, |
138 |
{ |
139 |
"max_nick_length", |
140 |
OUTPUT_DECIMAL, |
141 |
&ConfigServerInfo.max_nick_length, |
142 |
"Maximum nickname length" |
143 |
}, |
144 |
{ |
145 |
"max_topic_length", |
146 |
OUTPUT_DECIMAL, |
147 |
&ConfigServerInfo.max_topic_length, |
148 |
"Maximum topic length" |
149 |
}, |
150 |
{ |
151 |
"use_logging", |
152 |
OUTPUT_BOOLEAN_YN, |
153 |
&ConfigLog.use_logging, |
154 |
"Enable logging" |
155 |
}, |
156 |
{ |
157 |
"disable_fake_channels", |
158 |
OUTPUT_BOOLEAN_YN, |
159 |
&ConfigChannel.disable_fake_channels, |
160 |
"Forbids channels with special ASCII characters in their name" |
161 |
}, |
162 |
{ |
163 |
"invite_client_count", |
164 |
OUTPUT_DECIMAL, |
165 |
&ConfigChannel.invite_client_count, |
166 |
"How many INVITE attempts are permitted in invite_client_time" |
167 |
}, |
168 |
{ |
169 |
"invite_client_time", |
170 |
OUTPUT_DECIMAL, |
171 |
&ConfigChannel.invite_client_time, |
172 |
"How many invite_client_count invites are allowed in this time" |
173 |
}, |
174 |
{ |
175 |
"knock_client_count", |
176 |
OUTPUT_DECIMAL, |
177 |
&ConfigChannel.knock_client_count, |
178 |
"How many KNOCK attempts are permitted in knock_client_time" |
179 |
}, |
180 |
{ |
181 |
"knock_client_time", |
182 |
OUTPUT_DECIMAL, |
183 |
&ConfigChannel.knock_client_time, |
184 |
"How many knock_client_count knocks are allowed in this time" |
185 |
}, |
186 |
{ |
187 |
"knock_delay_channel", |
188 |
OUTPUT_DECIMAL, |
189 |
&ConfigChannel.knock_delay_channel, |
190 |
"Delay between KNOCK attempts to a channel" |
191 |
}, |
192 |
{ |
193 |
"max_channels", |
194 |
OUTPUT_DECIMAL, |
195 |
&ConfigChannel.max_channels, |
196 |
"Maximum number of channels a user can join" |
197 |
}, |
198 |
{ |
199 |
"max_bans", |
200 |
OUTPUT_DECIMAL, |
201 |
&ConfigChannel.max_bans, |
202 |
"Total +b/e/I modes allowed in a channel" |
203 |
}, |
204 |
{ |
205 |
"flatten_links", |
206 |
OUTPUT_BOOLEAN_YN, |
207 |
&ConfigServerHide.flatten_links, |
208 |
"Flatten /links list" |
209 |
}, |
210 |
{ |
211 |
"links_delay", |
212 |
OUTPUT_DECIMAL, |
213 |
&ConfigServerHide.links_delay, |
214 |
"Links rehash delay" |
215 |
}, |
216 |
{ |
217 |
"hidden", |
218 |
OUTPUT_BOOLEAN_YN, |
219 |
&ConfigServerHide.hidden, |
220 |
"Hide this server from a flattened /links on remote servers" |
221 |
}, |
222 |
{ |
223 |
"hide_servers", |
224 |
OUTPUT_BOOLEAN_YN, |
225 |
&ConfigServerHide.hide_servers, |
226 |
"Hide servernames from users" |
227 |
}, |
228 |
{ |
229 |
"hide_services", |
230 |
OUTPUT_BOOLEAN_YN, |
231 |
&ConfigServerHide.hide_services, |
232 |
"Hides the location of services server" |
233 |
}, |
234 |
{ |
235 |
"hidden_name", |
236 |
OUTPUT_STRING, |
237 |
&ConfigServerHide.hidden_name, |
238 |
"Server name users see if hide_servers = yes" |
239 |
}, |
240 |
{ |
241 |
"hide_server_ips", |
242 |
OUTPUT_BOOLEAN_YN, |
243 |
&ConfigServerHide.hide_server_ips, |
244 |
"Prevent people from seeing server IP addresses" |
245 |
}, |
246 |
{ |
247 |
"away_count", |
248 |
OUTPUT_DECIMAL, |
249 |
&ConfigGeneral.away_count, |
250 |
"How many AWAY attempts are permitted in away_time" |
251 |
}, |
252 |
{ |
253 |
"away_time", |
254 |
OUTPUT_DECIMAL, |
255 |
&ConfigGeneral.away_time, |
256 |
"How many away_count aways are allowed in this time" |
257 |
}, |
258 |
{ |
259 |
"dline_min_cidr", |
260 |
OUTPUT_DECIMAL, |
261 |
&ConfigGeneral.dline_min_cidr, |
262 |
"Minimum required length of a CIDR bitmask for IPv4 D-Lines" |
263 |
}, |
264 |
{ |
265 |
"dline_min_cidr6", |
266 |
OUTPUT_DECIMAL, |
267 |
&ConfigGeneral.dline_min_cidr6, |
268 |
"Minimum required length of a CIDR bitmask for IPv6 D-Lines" |
269 |
}, |
270 |
{ |
271 |
"kline_min_cidr", |
272 |
OUTPUT_DECIMAL, |
273 |
&ConfigGeneral.kline_min_cidr, |
274 |
"Minimum required length of a CIDR bitmask for IPv4 K-Lines" |
275 |
}, |
276 |
{ |
277 |
"kline_min_cidr6", |
278 |
OUTPUT_DECIMAL, |
279 |
&ConfigGeneral.kline_min_cidr6, |
280 |
"Minimum required length of a CIDR bitmask for IPv6 K-Lines" |
281 |
}, |
282 |
{ |
283 |
"invisible_on_connect", |
284 |
OUTPUT_BOOLEAN_YN, |
285 |
&ConfigGeneral.invisible_on_connect, |
286 |
"Automatically set mode +i on connecting users" |
287 |
}, |
288 |
{ |
289 |
"kill_chase_time_limit", |
290 |
OUTPUT_DECIMAL, |
291 |
&ConfigGeneral.kill_chase_time_limit, |
292 |
"Nick Change Tracker for KILL" |
293 |
}, |
294 |
{ |
295 |
"ignore_bogus_ts", |
296 |
OUTPUT_BOOLEAN_YN, |
297 |
&ConfigGeneral.ignore_bogus_ts, |
298 |
"Ignore bogus timestamps from other servers" |
299 |
}, |
300 |
{ |
301 |
"cycle_on_host_change", |
302 |
OUTPUT_BOOLEAN_YN, |
303 |
&ConfigGeneral.cycle_on_host_change, |
304 |
"Send a fake QUIT/JOIN combination on host change" |
305 |
}, |
306 |
{ |
307 |
"disable_auth", |
308 |
OUTPUT_BOOLEAN_YN, |
309 |
&ConfigGeneral.disable_auth, |
310 |
"Completely disable ident lookups" |
311 |
}, |
312 |
{ |
313 |
"disable_remote_commands", |
314 |
OUTPUT_BOOLEAN_YN, |
315 |
&ConfigServerHide.disable_remote_commands, |
316 |
"Prevent users issuing commands on remote servers" |
317 |
}, |
318 |
{ |
319 |
"tkline_expire_notices", |
320 |
OUTPUT_BOOLEAN_YN, |
321 |
&ConfigGeneral.tkline_expire_notices, |
322 |
"Show temporary kline/xline expire notices" |
323 |
}, |
324 |
{ |
325 |
"default_floodcount", |
326 |
OUTPUT_DECIMAL, |
327 |
&ConfigGeneral.default_floodcount, |
328 |
"Startup value of FLOODCOUNT" |
329 |
}, |
330 |
{ |
331 |
"failed_oper_notice", |
332 |
OUTPUT_BOOLEAN_YN, |
333 |
&ConfigGeneral.failed_oper_notice, |
334 |
"Inform opers if someone tries to /oper with the wrong password" |
335 |
}, |
336 |
{ |
337 |
"dots_in_ident", |
338 |
OUTPUT_DECIMAL, |
339 |
&ConfigGeneral.dots_in_ident, |
340 |
"Number of permissable dots in an ident" |
341 |
}, |
342 |
{ |
343 |
"min_nonwildcard", |
344 |
OUTPUT_DECIMAL, |
345 |
&ConfigGeneral.min_nonwildcard, |
346 |
"Minimum non-wildcard chars in K/D lines" |
347 |
}, |
348 |
{ |
349 |
"min_nonwildcard_simple", |
350 |
OUTPUT_DECIMAL, |
351 |
&ConfigGeneral.min_nonwildcard_simple, |
352 |
"Minimum non-wildcards in gecos bans" |
353 |
}, |
354 |
{ |
355 |
"max_watch", |
356 |
OUTPUT_DECIMAL, |
357 |
&ConfigGeneral.max_watch, |
358 |
"Maximum nicknames on watch list" |
359 |
}, |
360 |
{ |
361 |
"max_accept", |
362 |
OUTPUT_DECIMAL, |
363 |
&ConfigGeneral.max_accept, |
364 |
"Maximum nicknames on accept list" |
365 |
}, |
366 |
{ |
367 |
"anti_nick_flood", |
368 |
OUTPUT_BOOLEAN_YN, |
369 |
&ConfigGeneral.anti_nick_flood, |
370 |
"NICK flood protection" |
371 |
}, |
372 |
{ |
373 |
"max_nick_time", |
374 |
OUTPUT_DECIMAL, |
375 |
&ConfigGeneral.max_nick_time, |
376 |
"NICK flood protection time interval" |
377 |
}, |
378 |
{ |
379 |
"max_nick_changes", |
380 |
OUTPUT_DECIMAL, |
381 |
&ConfigGeneral.max_nick_changes, |
382 |
"NICK change threshhold setting" |
383 |
}, |
384 |
{ |
385 |
"anti_spam_exit_message_time", |
386 |
OUTPUT_DECIMAL, |
387 |
&ConfigGeneral.anti_spam_exit_message_time, |
388 |
"Duration a client must be connected for to have an exit message" |
389 |
}, |
390 |
{ |
391 |
"ts_warn_delta", |
392 |
OUTPUT_DECIMAL, |
393 |
&ConfigGeneral.ts_warn_delta, |
394 |
"Maximum permitted TS delta before displaying a warning" |
395 |
}, |
396 |
{ |
397 |
"ts_max_delta", |
398 |
OUTPUT_DECIMAL, |
399 |
&ConfigGeneral.ts_max_delta, |
400 |
"Maximum permitted TS delta from another server" |
401 |
}, |
402 |
{ |
403 |
"warn_no_connect_block", |
404 |
OUTPUT_BOOLEAN_YN, |
405 |
&ConfigGeneral.warn_no_connect_block, |
406 |
"Display warning if connecting server lacks a connect{} block" |
407 |
}, |
408 |
{ |
409 |
"stats_e_disabled", |
410 |
OUTPUT_BOOLEAN_YN, |
411 |
&ConfigGeneral.stats_e_disabled, |
412 |
"Whether or not STATS e is disabled" |
413 |
}, |
414 |
{ |
415 |
"stats_m_oper_only", |
416 |
OUTPUT_BOOLEAN_YN, |
417 |
&ConfigGeneral.stats_m_oper_only, |
418 |
"STATS m output is only shown to operators" |
419 |
}, |
420 |
{ |
421 |
"stats_o_oper_only", |
422 |
OUTPUT_BOOLEAN_YN, |
423 |
&ConfigGeneral.stats_o_oper_only, |
424 |
"STATS O output is only shown to operators" |
425 |
}, |
426 |
{ |
427 |
"stats_P_oper_only", |
428 |
OUTPUT_BOOLEAN_YN, |
429 |
&ConfigGeneral.stats_P_oper_only, |
430 |
"STATS P is only shown to operators" |
431 |
}, |
432 |
{ |
433 |
"stats_u_oper_only", |
434 |
OUTPUT_BOOLEAN_YN, |
435 |
&ConfigGeneral.stats_u_oper_only, |
436 |
"STATS u is only shown to operators" |
437 |
}, |
438 |
{ |
439 |
"stats_i_oper_only", |
440 |
OUTPUT_BOOLEAN2, |
441 |
&ConfigGeneral.stats_i_oper_only, |
442 |
"STATS I output is only shown to operators" |
443 |
}, |
444 |
{ |
445 |
"stats_k_oper_only", |
446 |
OUTPUT_BOOLEAN2, |
447 |
&ConfigGeneral.stats_k_oper_only, |
448 |
"STATS K output is only shown to operators" |
449 |
}, |
450 |
{ |
451 |
"caller_id_wait", |
452 |
OUTPUT_DECIMAL, |
453 |
&ConfigGeneral.caller_id_wait, |
454 |
"Minimum delay between notifying UMODE +g users of messages" |
455 |
}, |
456 |
{ |
457 |
"opers_bypass_callerid", |
458 |
OUTPUT_BOOLEAN_YN, |
459 |
&ConfigGeneral.opers_bypass_callerid, |
460 |
"Allows IRC operators to message users who are +g (callerid)" |
461 |
}, |
462 |
{ |
463 |
"pace_wait_simple", |
464 |
OUTPUT_DECIMAL, |
465 |
&ConfigGeneral.pace_wait_simple, |
466 |
"Minimum delay between less intensive commands" |
467 |
}, |
468 |
{ |
469 |
"pace_wait", |
470 |
OUTPUT_DECIMAL, |
471 |
&ConfigGeneral.pace_wait, |
472 |
"Minimum delay between uses of certain commands" |
473 |
}, |
474 |
{ |
475 |
"short_motd", |
476 |
OUTPUT_BOOLEAN_YN, |
477 |
&ConfigGeneral.short_motd, |
478 |
"Do not show MOTD; only tell clients they should read it" |
479 |
}, |
480 |
{ |
481 |
"ping_cookie", |
482 |
OUTPUT_BOOLEAN_YN, |
483 |
&ConfigGeneral.ping_cookie, |
484 |
"Require ping cookies to connect" |
485 |
}, |
486 |
{ |
487 |
"no_oper_flood", |
488 |
OUTPUT_BOOLEAN_YN, |
489 |
&ConfigGeneral.no_oper_flood, |
490 |
"Reduce flood control for operators" |
491 |
}, |
492 |
{ |
493 |
"max_targets", |
494 |
OUTPUT_DECIMAL, |
495 |
&ConfigGeneral.max_targets, |
496 |
"The maximum number of PRIVMSG/NOTICE targets" |
497 |
}, |
498 |
{ |
499 |
"throttle_count", |
500 |
OUTPUT_DECIMAL, |
501 |
&ConfigGeneral.throttle_count, |
502 |
"Number of connects in throttle_time before connections are blocked" |
503 |
}, |
504 |
{ |
505 |
"throttle_time", |
506 |
OUTPUT_DECIMAL, |
507 |
&ConfigGeneral.throttle_time, |
508 |
"Minimum time between client reconnects" |
509 |
}, |
510 |
|
511 |
/* --[ END OF TABLE ]---------------------------------------------- */ |
512 |
{ |
513 |
NULL, |
514 |
0, |
515 |
NULL, |
516 |
NULL |
517 |
} |
518 |
}; |
519 |
|
520 |
/* send_birthdate_online_time() |
521 |
* |
522 |
* inputs - client pointer to send to |
523 |
* output - NONE |
524 |
* side effects - birthdate and online time are sent |
525 |
*/ |
526 |
static void |
527 |
send_birthdate_online_time(struct Client *source_p) |
528 |
{ |
529 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
530 |
":On-line since %s", |
531 |
date(me.connection->firsttime)); |
532 |
} |
533 |
|
534 |
/* send_conf_options() |
535 |
* |
536 |
* inputs - client pointer to send to |
537 |
* output - NONE |
538 |
* side effects - send config options to client |
539 |
*/ |
540 |
static void |
541 |
send_conf_options(struct Client *source_p) |
542 |
{ |
543 |
/* |
544 |
* Parse the info_table[] and do the magic. |
545 |
*/ |
546 |
for (const struct InfoStruct *iptr = info_table; iptr->name; ++iptr) |
547 |
{ |
548 |
switch (iptr->output_type) |
549 |
{ |
550 |
/* For "char *" references */ |
551 |
case OUTPUT_STRING: |
552 |
{ |
553 |
const char *option = *((const char *const *)iptr->option); |
554 |
|
555 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
556 |
":%-30s %-5s [%s]", |
557 |
iptr->name, option ? option : "NONE", |
558 |
iptr->desc ? iptr->desc : "<none>"); |
559 |
break; |
560 |
} |
561 |
|
562 |
/* For "char foo[]" references */ |
563 |
case OUTPUT_STRING_PTR: |
564 |
{ |
565 |
const char *option = iptr->option; |
566 |
|
567 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
568 |
":%-30s %-5s [%s]", |
569 |
iptr->name, option ? option : "NONE", |
570 |
iptr->desc ? iptr->desc : "<none>"); |
571 |
break; |
572 |
} |
573 |
|
574 |
/* Output info_table[i].option as a decimal value. */ |
575 |
case OUTPUT_DECIMAL: |
576 |
{ |
577 |
const unsigned int option = *((const unsigned int *const)iptr->option); |
578 |
|
579 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
580 |
":%-30s %-5u [%s]", |
581 |
iptr->name, option, iptr->desc ? iptr->desc : "<none>"); |
582 |
break; |
583 |
} |
584 |
|
585 |
/* Output info_table[i].option as "ON" or "OFF" */ |
586 |
case OUTPUT_BOOLEAN: |
587 |
{ |
588 |
const unsigned int option = *((const unsigned int *const)iptr->option); |
589 |
|
590 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
591 |
":%-30s %-5s [%s]", |
592 |
iptr->name, option ? "ON" : "OFF", |
593 |
iptr->desc ? iptr->desc : "<none>"); |
594 |
|
595 |
break; |
596 |
} |
597 |
|
598 |
/* Output info_table[i].option as "YES" or "NO" */ |
599 |
case OUTPUT_BOOLEAN_YN: |
600 |
{ |
601 |
const unsigned int option = *((const unsigned int *const)iptr->option); |
602 |
|
603 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
604 |
":%-30s %-5s [%s]", |
605 |
iptr->name, option ? "YES" : "NO", |
606 |
iptr->desc ? iptr->desc : "<none>"); |
607 |
break; |
608 |
} |
609 |
|
610 |
case OUTPUT_BOOLEAN2: |
611 |
{ |
612 |
const unsigned int option = *((const unsigned int *const)iptr->option); |
613 |
|
614 |
sendto_one_numeric(source_p, &me, RPL_INFO | SND_EXPLICIT, |
615 |
":%-30s %-5s [%s]", |
616 |
iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO", |
617 |
iptr->desc ? iptr->desc : "<none>"); |
618 |
break; |
619 |
} |
620 |
} |
621 |
} |
622 |
|
623 |
sendto_one_numeric(source_p, &me, RPL_INFO, ""); |
624 |
} |
625 |
|
626 |
/* send_info_text() |
627 |
* |
628 |
* inputs - client pointer to send info text to |
629 |
* output - NONE |
630 |
* side effects - info text is sent to client |
631 |
*/ |
632 |
static void |
633 |
send_info_text(struct Client *source_p) |
634 |
{ |
635 |
sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE, |
636 |
"INFO requested by %s (%s@%s) [%s]", |
637 |
source_p->name, source_p->username, |
638 |
source_p->host, source_p->servptr->name); |
639 |
|
640 |
for (const char **text = infotext; *text; ++text) |
641 |
{ |
642 |
const char *line = *text; |
643 |
|
644 |
if (*line == '\0') |
645 |
line = " "; |
646 |
|
647 |
sendto_one_numeric(source_p, &me, RPL_INFO, line); |
648 |
} |
649 |
|
650 |
if (HasUMode(source_p, UMODE_OPER)) |
651 |
send_conf_options(source_p); |
652 |
|
653 |
send_birthdate_online_time(source_p); |
654 |
|
655 |
sendto_one_numeric(source_p, &me, RPL_ENDOFINFO); |
656 |
} |
657 |
|
658 |
/*! \brief INFO command handler |
659 |
* |
660 |
* \param source_p Pointer to allocated Client struct from which the message |
661 |
* originally comes from. This can be a local or remote client. |
662 |
* \param parc Integer holding the number of supplied arguments. |
663 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
664 |
* pointers. |
665 |
* \note Valid arguments for this command are: |
666 |
* - parv[0] = command |
667 |
* - parv[1] = nickname/servername |
668 |
*/ |
669 |
static int |
670 |
m_info(struct Client *source_p, int parc, char *parv[]) |
671 |
{ |
672 |
static time_t last_used = 0; |
673 |
|
674 |
if ((last_used + ConfigGeneral.pace_wait) > CurrentTime) |
675 |
{ |
676 |
sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "INFO"); |
677 |
return 0; |
678 |
} |
679 |
|
680 |
last_used = CurrentTime; |
681 |
|
682 |
if (!ConfigServerHide.disable_remote_commands) |
683 |
if (hunt_server(source_p, ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME) |
684 |
return 0; |
685 |
|
686 |
send_info_text(source_p); |
687 |
return 0; |
688 |
} |
689 |
|
690 |
/*! \brief INFO command handler |
691 |
* |
692 |
* \param source_p Pointer to allocated Client struct from which the message |
693 |
* originally comes from. This can be a local or remote client. |
694 |
* \param parc Integer holding the number of supplied arguments. |
695 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
696 |
* pointers. |
697 |
* \note Valid arguments for this command are: |
698 |
* - parv[0] = command |
699 |
* - parv[1] = nickname/servername |
700 |
*/ |
701 |
static int |
702 |
ms_info(struct Client *source_p, int parc, char *parv[]) |
703 |
{ |
704 |
if (hunt_server(source_p, ":%s INFO :%s", 1, parc, parv) != HUNTED_ISME) |
705 |
return 0; |
706 |
|
707 |
send_info_text(source_p); |
708 |
return 0; |
709 |
} |
710 |
|
711 |
static struct Message info_msgtab = |
712 |
{ |
713 |
.cmd = "INFO", |
714 |
.args_max = MAXPARA, |
715 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
716 |
.handlers[CLIENT_HANDLER] = m_info, |
717 |
.handlers[SERVER_HANDLER] = ms_info, |
718 |
.handlers[ENCAP_HANDLER] = m_ignore, |
719 |
.handlers[OPER_HANDLER] = ms_info |
720 |
}; |
721 |
|
722 |
static void |
723 |
module_init(void) |
724 |
{ |
725 |
mod_add_cmd(&info_msgtab); |
726 |
} |
727 |
|
728 |
static void |
729 |
module_exit(void) |
730 |
{ |
731 |
mod_del_cmd(&info_msgtab); |
732 |
} |
733 |
|
734 |
struct module module_entry = |
735 |
{ |
736 |
.version = "$Revision$", |
737 |
.modinit = module_init, |
738 |
.modexit = module_exit, |
739 |
}; |