summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--include/extern.h1
-rw-r--r--include/services.h16
-rw-r--r--src/core/os_stats.c126
-rw-r--r--src/servers.c133
-rw-r--r--version.log6
6 files changed, 83 insertions, 200 deletions
diff --git a/Changes b/Changes
index 3ffdc8e2a..abf2fae0b 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,7 @@ Provided by Anope Dev. <dev@anope.org> - 2005
10/01 A Information on uplink server can be displayed via OperServ STATS. [ #00]
09/29 A Configuration option to change fantasy command prefix character. [ #00]
09/28 A Event for fantasy commands triggered without channel access. [ #00]
+10/01 F Placed capab tokens and flags into a table for easier handling. [ #00]
10/01 F Capab parsing on hybrid/plexus/ratbox failed. [ #00]
10/01 F Typo in example.conf (DevNullAlias was called DevNullName). [ #00]
10/01 F UserKeys gave an error without message when missing. [ #00]
diff --git a/include/extern.h b/include/extern.h
index 51a78a684..11af90253 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -988,6 +988,7 @@ E Server *servlist;
E Server *me_server;
E Server *serv_uplink;
E uint32 uplink_capab;
+E CapabInfo capab_info[];
E Server *first_server(int flags);
E Server *next_server(int flags);
diff --git a/include/services.h b/include/services.h
index e0017256e..b155c9f47 100644
--- a/include/services.h
+++ b/include/services.h
@@ -1282,18 +1282,26 @@ typedef struct ircd_modes_ {
#define MUT_DEPROTECT 6
#define MUT_PROTECT 7
+/*************************************************************************/
+/* CAPAB stuffs */
+
+typedef struct capabinfo_ CapabInfo;
+struct capabinfo_ {
+ char *token;
+ uint32 flag;
+};
-#define CAPAB_NOQUIT 0x00000001
-#define CAPAB_TSMODE 0x00000002
+#define CAPAB_NOQUIT 0x00000001
+#define CAPAB_TSMODE 0x00000002
#define CAPAB_UNCONNECT 0x00000004
#define CAPAB_NICKIP 0x00000008
#define CAPAB_NSJOIN 0x00000010
-#define CAPAB_ZIP 0x00000020
+#define CAPAB_ZIP 0x00000020
#define CAPAB_BURST 0x00000040
#define CAPAB_TS3 0x00000080
#define CAPAB_TS5 0x00000100
#define CAPAB_DKEY 0x00000200
-#define CAPAB_DOZIP 0x00000400
+#define CAPAB_DOZIP 0x00000400
#define CAPAB_DODKEY 0x00000800
#define CAPAB_QS 0x00001000
#define CAPAB_SCS 0x00002000
diff --git a/src/core/os_stats.c b/src/core/os_stats.c
index 9171287f8..7e15d018e 100644
--- a/src/core/os_stats.c
+++ b/src/core/os_stats.c
@@ -103,6 +103,7 @@ int do_stats(User * u)
char timebuf[64];
char buf[512];
int buflen;
+ int i;
if (extra && stricmp(extra, "ALL") != 0) {
if (stricmp(extra, "AKILL") == 0) {
@@ -304,113 +305,30 @@ int do_stats(User * u)
}
if (extra && ((stricmp(extra, "ALL") == 0) || (stricmp(extra, "UPLINK") == 0)) && is_services_admin(u)) {
- notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name);
buf[0] = '\0';
buflen = 511; /* How confusing, this is the amount of space left! */
- if (uplink_capab & CAPAB_NOQUIT) {
- strncat(buf, " NOQUIT", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_TSMODE) {
- strncat(buf, " TSMODE", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_UNCONNECT) {
- strncat(buf, " UNCONNECT", buflen);
- buflen -= 10;
- }
- if (uplink_capab & CAPAB_NICKIP) {
- strncat(buf, " NICKIP", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_NSJOIN) {
- strncat(buf, " SSJOIN", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_ZIP) {
- strncat(buf, " ZIP", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_BURST) {
- strncat(buf, " BURST", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_TS5) {
- strncat(buf, " TS5", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_TS3) {
- strncat(buf, " TS3", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_DKEY) {
- strncat(buf, " DKEY", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_PT4) {
- strncat(buf, " PT4", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_SCS) {
- strncat(buf, " SCS", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_QS) {
- strncat(buf, " QS", buflen);
- buflen -= 3;
- }
- if (uplink_capab & CAPAB_UID) {
- strncat(buf, " UID", buflen);
- buflen -= 4;
- }
- if (uplink_capab & CAPAB_KNOCK) {
- strncat(buf, " KNOCK", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_CLIENT) {
- strncat(buf, " CLIENT", buflen);
- buflen -= 7;
- }
- if (uplink_capab & CAPAB_IPV6) {
- strncat(buf, " IPV6", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SSJ5) {
- strncat(buf, " SSJ5", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SN2) {
- strncat(buf, " SN2", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_TOKEN) {
- strncat(buf, " TOKEN", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_VHOST) {
- strncat(buf, " VHOST", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_SSJ3) {
- strncat(buf, " SSJ3", buflen);
- buflen -= 5;
- }
- if (uplink_capab & CAPAB_SJB64) {
- strncat(buf, " SJB64", buflen);
- buflen -= 6;
- }
- if (uplink_capab & CAPAB_CHANMODE) {
- strncat(buf, " CHANMODES=", buflen);
- buflen -= 11;
- strncat(buf, ircd->chanmodes, buflen);
- buflen -= strlen(ircd->chanmodes);
- }
- if (uplink_capab & CAPAB_NICKCHARS) {
- strncat(buf, " NICKCHARS=", buflen);
- buflen -= 11;
- strncat(buf, ircd->nickchars, buflen);
- buflen -= strlen(ircd->nickchars);
+ for (i = 0; capab_info[i].token; i++) {
+ if (uplink_capab & capab_info[i].flag) {
+ strncat(buf, " ", buflen);
+ buflen--;
+ strncat(buf, capab_info[i].token, buflen);
+ buflen -= strlen(capab_info[i].token);
+ /* Special cases */
+ if (capab_info[i].flag == CAPAB_CHANMODE) {
+ strncat(buf, "=", buflen);
+ buflen--;
+ strncat(buf, ircd->chanmodes, buflen);
+ buflen -= strlen(ircd->chanmodes);
+ }
+ if (capab_info[i].flag == CAPAB_NICKCHARS) {
+ strncat(buf, "=", buflen);
+ buflen--;
+ strncat(buf, ircd->nickchars, buflen);
+ buflen -= strlen(ircd->nickchars);
+ }
+ }
}
+ notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name);
notice_lang(s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf);
notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(serv_uplink));
}
diff --git a/src/servers.c b/src/servers.c
index 0a076c334..ace20dfa8 100644
--- a/src/servers.c
+++ b/src/servers.c
@@ -25,6 +25,36 @@ char *TS6SID;
/* For first_server / next_server */
static Server *server_cur;
+CapabInfo capab_info[] = {
+ {"NOQUIT", CAPAB_NOQUIT},
+ {"TSMODE", CAPAB_TSMODE},
+ {"UNCONNECT", CAPAB_UNCONNECT},
+ {"NICKIP", CAPAB_NICKIP},
+ {"SSJOIN", CAPAB_NSJOIN},
+ {"ZIP", CAPAB_ZIP},
+ {"BURST", CAPAB_BURST},
+ {"TS5", CAPAB_TS5},
+ {"TS3", CAPAB_TS3},
+ {"DKEY", CAPAB_DKEY},
+ {"PT4", CAPAB_PT4},
+ {"SCS", CAPAB_SCS},
+ {"QS", CAPAB_QS},
+ {"UID", CAPAB_UID},
+ {"KNOCK", CAPAB_KNOCK},
+ {"CLIENT", CAPAB_CLIENT},
+ {"IPV6", CAPAB_IPV6},
+ {"SSJ5", CAPAB_SSJ5},
+ {"SN2", CAPAB_SN2},
+ {"TOK1", CAPAB_TOKEN},
+ {"TOKEN", CAPAB_TOKEN},
+ {"VHOST", CAPAB_VHOST},
+ {"SSJ3", CAPAB_SSJ3},
+ {"SJB64", CAPAB_SJB64},
+ {"CHANMODES", CAPAB_CHANMODE},
+ {"NICKCHARS", CAPAB_NICKCHARS},
+ {NULL, 0}
+};
+
/*************************************************************************/
/**
@@ -402,6 +432,7 @@ void do_squit(const char *source, int ac, char **av)
void capab_parse(int ac, char **av)
{
int i;
+ int j;
char *s, *tmp;
char *temp;
@@ -412,105 +443,25 @@ void capab_parse(int ac, char **av)
s = myStrGetToken(temp, '=', 0);
tmp = myStrGetTokenRemainder(temp, '=', 1);
- if (!s) {
+ if (!s)
continue;
- }
- if (!stricmp(s, "NOQUIT")) {
- uplink_capab |= CAPAB_NOQUIT;
- }
- if (!stricmp(s, "TSMODE")) {
- uplink_capab |= CAPAB_TSMODE;
- }
- if (!stricmp(av[i], "UNCONNECT")) {
- uplink_capab |= CAPAB_UNCONNECT;
- }
- if (!stricmp(s, "NICKIP")) {
- uplink_capab |= CAPAB_NICKIP;
- /* Update the struct so that we know we can get NICKIP */
- if (!ircd->nickip) {
+ for (j = 0; capab_info[j].token; j++) {
+ if (stricmp(s, capab_info[j].token) == 0)
+ uplink_capab |= capab_info[j].flag;
+ /* Special cases */
+ if ((stricmp(s, "NICKIP") == 0) && !ircd->nickip)
ircd->nickip = 1;
- }
- }
- if (!stricmp(s, "SSJOIN")) {
- uplink_capab |= CAPAB_NSJOIN;
- }
- if (!stricmp(s, "ZIP")) {
- uplink_capab |= CAPAB_ZIP;
- }
- if (!stricmp(s, "BURST")) {
- uplink_capab |= CAPAB_BURST;
- }
- if (!stricmp(s, "TS5")) {
- uplink_capab |= CAPAB_TS5;
- }
- if (!stricmp(s, "TS3")) {
- uplink_capab |= CAPAB_TS3;
- }
- if (!stricmp(s, "DKEY")) {
- uplink_capab |= CAPAB_DKEY;
- }
- if (!stricmp(s, "PT4")) {
- uplink_capab |= CAPAB_PT4;
- }
- if (!stricmp(s, "SCS")) {
- uplink_capab |= CAPAB_SCS;
- }
- if (!stricmp(s, "QS")) {
- uplink_capab |= CAPAB_QS;
- }
- if (!stricmp(s, "UID")) {
- uplink_capab |= CAPAB_UID;
- }
- if (!stricmp(s, "KNOCK")) {
- uplink_capab |= CAPAB_KNOCK;
- }
- if (!stricmp(s, "CLIENT")) {
- uplink_capab |= CAPAB_CLIENT;
- }
- if (!stricmp(s, "IPV6")) {
- uplink_capab |= CAPAB_IPV6;
- }
- if (!stricmp(s, "SSJ5")) {
- uplink_capab |= CAPAB_SSJ5;
- }
- if (!stricmp(s, "SN2")) {
- uplink_capab |= CAPAB_SN2;
- }
- if (!stricmp(s, "TOK1")) {
- uplink_capab |= CAPAB_TOKEN;
- }
- if (!stricmp(s, "TOKEN")) {
- uplink_capab |= CAPAB_TOKEN;
- }
- if (!stricmp(s, "VHOST")) {
- uplink_capab |= CAPAB_VHOST;
- }
- if (!stricmp(s, "SSJ3")) {
- uplink_capab |= CAPAB_SSJ3;
- }
- if (!stricmp(s, "SJB64")) {
- uplink_capab |= CAPAB_SJB64;
- }
- if (!stricmp(s, "CHANMODES")) {
- uplink_capab |= CAPAB_CHANMODE;
- if (tmp) {
+ if ((stricmp(s, "CHANMODES") == 0) && tmp)
ircd->chanmodes = sstrdup(tmp);
- }
- }
- if (!stricmp(s, "NICKCHARS")) {
- uplink_capab |= CAPAB_NICKCHARS;
- if (tmp) {
+ if ((stricmp(s, "NICKCHARS") == 0) && tmp)
ircd->nickchars = sstrdup(tmp);
- }
}
- if (s) {
+
+ if (s)
free(s);
- }
- if (tmp) {
+ if (tmp)
free(tmp);
- }
-
}
}
diff --git a/version.log b/version.log
index 7b7f6da72..4b88e6dea 100644
--- a/version.log
+++ b/version.log
@@ -9,10 +9,14 @@ VERSION_MAJOR="1"
VERSION_MINOR="7"
VERSION_PATCH="11"
VERSION_EXTRA="-svn"
-VERSION_BUILD="907"
+VERSION_BUILD="908"
# $Log$
#
+# BUILD : 1.7.11 (908)
+# BUGS :
+# NOTES : Created a CapabInfo table to allow easier handling of capab tokens/flags
+#
# BUILD : 1.7.11 (907)
# BUGS :
# NOTES : Fixed capab parsing on hybrid/plexus/ratbox and a typo in example.conf