From 07db71cda082d1d7db7bec491bb60aee5f1e2879 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Mon, 11 Oct 2010 16:35:18 -0400 Subject: [PATCH] Fix VERSION and RPL_MYINFO to only show modes that are enabled. Also fix up some errors from the last commit. --- doc/reference.conf | 1 + include/chmode.h | 1 + src/chmode.c | 24 ++++++++++++++++++++++-- src/messages.tab | 2 +- src/s_conf.c | 7 ++++--- src/s_user.c | 2 +- src/supported.c | 4 +++- 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/doc/reference.conf b/doc/reference.conf index 6b17503..8a08266 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -747,6 +747,7 @@ channel { * remote servers/users (ex: services) from setting them. Make sure * your services and remote servers are properly configured when * using this option! + * Valid parameters are: CLPFQITDENGJKMrczgqefj */ #disabledmodes = "ME"; diff --git a/include/chmode.h b/include/chmode.h index 82d8ecd..a4fc8f3 100644 --- a/include/chmode.h +++ b/include/chmode.h @@ -87,5 +87,6 @@ extern void cflag_orphan(char c); extern void construct_cflags_strings(void); extern char cflagsbuf[256]; extern char cflagsmyinfo[256]; +extern char cflagsparaminfo[256]; #endif diff --git a/src/chmode.c b/src/chmode.c index a135369..4c86b3d 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -43,6 +43,7 @@ #include "chmode.h" #include "irc_dictionary.h" + /* bitmasks for error returns, so we send once per call */ #define SM_ERR_NOTS 0x00000001 /* No TS on channel */ #define SM_ERR_NOOPS 0x00000002 /* No chan ops */ @@ -69,6 +70,7 @@ static int no_override_deop; char cflagsbuf[256]; char cflagsmyinfo[256]; +char cflagsparaminfo[256]; int chmode_flags[256]; @@ -120,14 +122,17 @@ construct_cflags_strings(void) break; default: - if(chmode_flags[i] != 0) + if(chmode_flags[i] != 0 && !(chmode_table[i].set_func == chm_orphaned)) { *ptr++ = (char) i; } } /* Should we leave orphaned check here? -- dwr */ - if(!(chmode_table[i].set_func == chm_nosuch) && !(chmode_table[i].set_func == chm_orphaned)) + if( !(chmode_table[i].set_func == chm_nosuch) && + !(chmode_table[i].set_func == chm_orphaned) && + !(chmode_table[i].set_func == chm_admin && !ConfigChannel.use_admin) && + !(chmode_table[i].set_func == chm_halfop && !ConfigChannel.use_halfop)) { *ptr2++ = (char) i; } @@ -137,6 +142,21 @@ construct_cflags_strings(void) *ptr2++ = '\0'; } +void +construct_cflag_param_string(void) +{ + + *cflagsparaminfo = '\0'; + rb_snprintf(cflagsparaminfo, sizeof cflagsparaminfo, "%sb%s%s%s%sklov%s%s", + ConfigChannel.use_admin ? "a" : "", + ConfigChannel.use_except ? "e" : "", + ConfigChannel.use_forward ? "f" : "", + ConfigChannel.use_halfop ? "h" : "", + strcasecmp(ConfigChannel.disabledmodes, "j") ? "" : "j", + strcasecmp(ConfigChannel.disabledmodes, "q") ? "" : "q", + ConfigChannel.use_invex ? "I" : ""); +} + /* * find_umode_slot * diff --git a/src/messages.tab b/src/messages.tab index d2af219..b23ffa8 100644 --- a/src/messages.tab +++ b/src/messages.tab @@ -24,7 +24,7 @@ static const char * replies[] = { /* 001 RPL_WELCOME, */ ":Welcome to the %s Internet Relay Chat Network %s", /* 002 RPL_YOURHOST,*/ ":Your host is %s, running version %s", /* 003 RPL_CREATED, */ ":This server was created %s", -/* 004 RPL_MYINFO, */ "%s %s %s %s bkloveqjfI", +/* 004 RPL_MYINFO, */ "%s %s %s %s %s", /* 005 RPL_ISUPPORT, */ "%s :are supported by this server", /* 006 */ NULL, /* 007 */ NULL, diff --git a/src/s_conf.c b/src/s_conf.c index 1f3e742..e09b41f 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1005,19 +1005,19 @@ validate_conf(void) if(*dm == 'I') { cflag_orphan('I'); - ConfigChannel.use_invex = "NO"; + ConfigChannel.use_invex = 0; continue; } if(*dm == 'e') { cflag_orphan('e'); - ConfigChannel.use_except = "NO"; + ConfigChannel.use_except = 0; continue; } if(*dm == 'f') { cflag_orphan('f'); - ConfigChannel.use_forward = "NO"; + ConfigChannel.use_forward = 0; continue; } if(*dm == 'j') @@ -1067,6 +1067,7 @@ validate_conf(void) } } } + construct_cflag_param_string(); startup = 0; } diff --git a/src/s_user.c b/src/s_user.c index aa8b17e..b81fe83 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1293,7 +1293,7 @@ user_welcome(struct Client *source_p) sendto_one_numeric(source_p, RPL_YOURHOST, form_str(RPL_YOURHOST), get_listener_name(source_p->localClient->listener), ircd_version); sendto_one_numeric(source_p, RPL_CREATED, form_str(RPL_CREATED), creation); - sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf, cflagsmyinfo); + sendto_one_numeric(source_p, RPL_MYINFO, form_str(RPL_MYINFO), me.name, ircd_version, umodebuf, cflagsmyinfo, cflagsparaminfo); show_isupport(source_p); diff --git a/src/supported.c b/src/supported.c index 49f0da4..417d4ab 100644 --- a/src/supported.c +++ b/src/supported.c @@ -235,10 +235,12 @@ isupport_chanmodes(const void *ptr) { static char result[80]; - rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,%s", + rb_snprintf(result, sizeof result, "%s%sb%s,k,%sl%s,%s", ConfigChannel.use_except ? "e" : "", ConfigChannel.use_invex ? "I" : "", + strcasecmp(ConfigChannel.disabledmodes, "q") ? "" : "q", ConfigChannel.use_forward ? "f" : "", + strcasecmp(ConfigChannel.disabledmodes, "j") ? "" : "j", cflagsbuf); return result; }