29 |
|
#include "client.h" |
30 |
|
#include "ircd.h" |
31 |
|
#include "numeric.h" |
32 |
< |
#include "s_misc.h" |
33 |
< |
#include "s_serv.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 |
< |
unsigned int output_type; /* See below #defines */ |
58 |
< |
void *option; /* Pointer reference to the value */ |
59 |
< |
const char *desc; /* ASCII description of the variable */ |
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 |
|
|
51 |
– |
/* Types for output_type in InfoStruct */ |
52 |
– |
#define OUTPUT_STRING 0x0001 /* Output option as %s w/ dereference */ |
53 |
– |
#define OUTPUT_STRING_PTR 0x0002 /* Output option as %s w/out deference */ |
54 |
– |
#define OUTPUT_DECIMAL 0x0004 /* Output option as decimal (%d) */ |
55 |
– |
#define OUTPUT_BOOLEAN 0x0008 /* Output option as "ON" or "OFF" */ |
56 |
– |
#define OUTPUT_BOOLEAN_YN 0x0010 /* Output option as "YES" or "NO" */ |
57 |
– |
#define OUTPUT_BOOLEAN2 0x0020 /* Output option as "YES/NO/MASKED" */ |
58 |
– |
|
62 |
|
static const struct InfoStruct info_table[] = |
63 |
|
{ |
64 |
|
/* --[ START OF TABLE ]-------------------------------------------- */ |
329 |
|
}, |
330 |
|
{ |
331 |
|
"failed_oper_notice", |
332 |
< |
OUTPUT_BOOLEAN, |
332 |
> |
OUTPUT_BOOLEAN_YN, |
333 |
|
&ConfigFileEntry.failed_oper_notice, |
334 |
|
"Inform opers if someone tries to /oper with the wrong password" |
335 |
|
}, |
359 |
|
}, |
360 |
|
{ |
361 |
|
"anti_nick_flood", |
362 |
< |
OUTPUT_BOOLEAN, |
362 |
> |
OUTPUT_BOOLEAN_YN, |
363 |
|
&ConfigFileEntry.anti_nick_flood, |
364 |
|
"NICK flood protection" |
365 |
|
}, |
394 |
|
"Maximum permitted TS delta from another server" |
395 |
|
}, |
396 |
|
{ |
397 |
< |
"warn_no_nline", |
398 |
< |
OUTPUT_BOOLEAN, |
399 |
< |
&ConfigFileEntry.warn_no_nline, |
400 |
< |
"Display warning if connecting server lacks N-line" |
397 |
> |
"warn_no_connect_block", |
398 |
> |
OUTPUT_BOOLEAN_YN, |
399 |
> |
&ConfigFileEntry.warn_no_connect_block, |
400 |
> |
"Display warning if connecting server lacks a connect{} block" |
401 |
|
}, |
402 |
|
{ |
403 |
|
"stats_e_disabled", |
467 |
|
}, |
468 |
|
{ |
469 |
|
"ping_cookie", |
470 |
< |
OUTPUT_BOOLEAN, |
470 |
> |
OUTPUT_BOOLEAN_YN, |
471 |
|
&ConfigFileEntry.ping_cookie, |
472 |
|
"Require ping cookies to connect" |
473 |
|
}, |
474 |
|
{ |
475 |
|
"no_oper_flood", |
476 |
< |
OUTPUT_BOOLEAN, |
476 |
> |
OUTPUT_BOOLEAN_YN, |
477 |
|
&ConfigFileEntry.no_oper_flood, |
478 |
|
"Reduce flood control for operators" |
479 |
|
}, |
480 |
|
{ |
481 |
|
"true_no_oper_flood", |
482 |
< |
OUTPUT_BOOLEAN, |
482 |
> |
OUTPUT_BOOLEAN_YN, |
483 |
|
&ConfigFileEntry.true_no_oper_flood, |
484 |
|
"Completely disable flood control for operators" |
485 |
|
}, |
502 |
|
"Minimum time between client reconnects" |
503 |
|
}, |
504 |
|
{ |
505 |
< |
"glines", |
506 |
< |
OUTPUT_BOOLEAN, |
505 |
> |
"gline_enable", |
506 |
> |
OUTPUT_BOOLEAN_YN, |
507 |
|
&ConfigFileEntry.glines, |
508 |
|
"G-line (network-wide K-line) support" |
509 |
|
}, |
538 |
|
static void |
539 |
|
send_birthdate_online_time(struct Client *source_p) |
540 |
|
{ |
541 |
< |
sendto_one(source_p, ":%s %d %s :On-line since %s", |
542 |
< |
ID_or_name(&me, source_p), RPL_INFO, |
543 |
< |
ID_or_name(source_p, source_p), |
541 |
< |
myctime(me.localClient->firsttime)); |
541 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
542 |
> |
":On-line since %s", |
543 |
> |
myctime(me.localClient->firsttime)); |
544 |
|
} |
545 |
|
|
546 |
|
/* send_conf_options() |
552 |
|
static void |
553 |
|
send_conf_options(struct Client *source_p) |
554 |
|
{ |
553 |
– |
const struct InfoStruct *iptr = NULL; |
554 |
– |
|
555 |
|
/* |
556 |
|
* Parse the info_table[] and do the magic. |
557 |
|
*/ |
558 |
< |
for (iptr = info_table; iptr->name; ++iptr) |
558 |
> |
for (const struct InfoStruct *iptr = info_table; iptr->name; ++iptr) |
559 |
|
{ |
560 |
|
switch (iptr->output_type) |
561 |
|
{ |
562 |
|
/* For "char *" references */ |
563 |
|
case OUTPUT_STRING: |
564 |
|
{ |
565 |
< |
const char *option = *((char **)iptr->option); |
565 |
> |
const char *option = *((const char *const *)iptr->option); |
566 |
|
|
567 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
568 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
569 |
< |
iptr->name, option ? option : "NONE", |
570 |
< |
iptr->desc ? iptr->desc : "<none>"); |
567 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
568 |
> |
":%-30s %-5s [%-30s]", |
569 |
> |
iptr->name, option ? option : "NONE", |
570 |
> |
iptr->desc ? iptr->desc : "<none>"); |
571 |
|
break; |
572 |
|
} |
573 |
|
|
576 |
|
{ |
577 |
|
const char *option = iptr->option; |
578 |
|
|
579 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
580 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
581 |
< |
iptr->name, option ? option : "NONE", |
582 |
< |
iptr->desc ? iptr->desc : "<none>"); |
579 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
580 |
> |
":%-30s %-5s [%-30s]", |
581 |
> |
iptr->name, option ? option : "NONE", |
582 |
> |
iptr->desc ? iptr->desc : "<none>"); |
583 |
|
break; |
584 |
|
} |
585 |
|
|
586 |
|
/* Output info_table[i].option as a decimal value. */ |
587 |
|
case OUTPUT_DECIMAL: |
588 |
|
{ |
589 |
< |
const int option = *((int *)iptr->option); |
589 |
> |
const int option = *((const int *const)iptr->option); |
590 |
|
|
591 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5d [%-30s]", |
592 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
593 |
< |
iptr->name, option, iptr->desc ? iptr->desc : "<none>"); |
591 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
592 |
> |
":%-30s %-5d [%-30s]", |
593 |
> |
iptr->name, option, iptr->desc ? iptr->desc : "<none>"); |
594 |
|
break; |
595 |
|
} |
596 |
|
|
597 |
|
/* Output info_table[i].option as "ON" or "OFF" */ |
598 |
|
case OUTPUT_BOOLEAN: |
599 |
|
{ |
600 |
< |
const int option = *((int *)iptr->option); |
600 |
> |
const int option = *((const int *const)iptr->option); |
601 |
|
|
602 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
603 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
604 |
< |
iptr->name, option ? "ON" : "OFF", |
605 |
< |
iptr->desc ? iptr->desc : "<none>"); |
602 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
603 |
> |
":%-30s %-5s [%-30s]", |
604 |
> |
iptr->name, option ? "ON" : "OFF", |
605 |
> |
iptr->desc ? iptr->desc : "<none>"); |
606 |
|
|
607 |
|
break; |
608 |
|
} |
610 |
|
/* Output info_table[i].option as "YES" or "NO" */ |
611 |
|
case OUTPUT_BOOLEAN_YN: |
612 |
|
{ |
613 |
< |
const int option = *((int *)iptr->option); |
613 |
> |
const int option = *((const int *const)iptr->option); |
614 |
|
|
615 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
616 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
617 |
< |
iptr->name, option ? "YES" : "NO", |
618 |
< |
iptr->desc ? iptr->desc : "<none>"); |
615 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
616 |
> |
":%-30s %-5s [%-30s]", |
617 |
> |
iptr->name, option ? "YES" : "NO", |
618 |
> |
iptr->desc ? iptr->desc : "<none>"); |
619 |
|
break; |
620 |
|
} |
621 |
|
|
622 |
|
case OUTPUT_BOOLEAN2: |
623 |
|
{ |
624 |
< |
const int option = *((int *)iptr->option); |
624 |
> |
const int option = *((const int *const)iptr->option); |
625 |
|
|
626 |
< |
sendto_one(source_p, ":%s %d %s :%-30s %-5s [%-30s]", |
627 |
< |
ID_or_name(&me, source_p), RPL_INFO, ID_or_name(source_p, source_p), |
628 |
< |
iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO", |
629 |
< |
iptr->desc ? iptr->desc : "<none>"); |
626 |
> |
sendto_one_numeric(source_p, &me, RPL_INFO|SND_EXPLICIT, |
627 |
> |
":%-30s %-5s [%-30s]", |
628 |
> |
iptr->name, option ? ((option == 1) ? "MASK" : "YES") : "NO", |
629 |
> |
iptr->desc ? iptr->desc : "<none>"); |
630 |
|
break; |
631 |
|
} |
632 |
|
} |