]> jfr.im git - solanum.git/commitdiff
Add support for customizing the usable nick length.
authorWilliam Pitcock <redacted>
Tue, 29 Nov 2011 22:10:21 +0000 (16:10 -0600)
committerWilliam Pitcock <redacted>
Tue, 29 Nov 2011 22:10:21 +0000 (16:10 -0600)
This adds a new ISUPPORT token, NICKLEN_USABLE which is strictly an informative value.
NICKLEN is always the maximum runtime NICKLEN supported by the IRCd, as other servers may
have their own usable NICKLEN settings.  As NICKLEN_USABLE is strictly informative, and
NICKLEN is always the maximum possible NICKLEN, any clients which depend on NICKLEN for
memory preallocation will be unaffected by runtime changes to NICKLEN_USABLE.

The default NICKLEN is 50; the default serverinfo::nicklen in the config file is set to
30, which is the NICKLEN presently used on StaticBox.

configure
configure.ac
doc/example.conf
doc/reference.conf
include/s_conf.h
modules/core/m_nick.c
src/ircd.c
src/newconf.c
src/s_conf.c
src/supported.c

index 3739e8e2da08f3854c0aa0a95bca04a3da22d41c..ef8f97511bede5c8f407daf43195bb0457bd397a 100755 (executable)
--- a/configure
+++ b/configure
@@ -1374,7 +1374,8 @@ Optional Packages:
                           Custom branding name.
   --with-custom-version=NAME
                           Custom version branding.
-  --with-nicklen=LENGTH   Set the nick length to LENGTH (default 15, max 50)
+  --with-nicklen=LENGTH   Set the upper-bound nick length to LENGTH (default
+                          50, max 50)
   --with-topiclen=NUMBER  Set the max topic length to NUMBER (default 390, max
                           390)
 
@@ -7916,7 +7917,7 @@ $as_echo "$as_me: WARNING: NICKLEN has a hard limit of 50. Setting NICKLEN=50" >
   fi
 
 else
-  NICKLEN=15
+  NICKLEN=50
 fi
 
 
index f68652f2e4f2db295681ecbde9357b9e68f28512..a6e1b45f71b579074f6dd5683e5286f44ea48ac4 100644 (file)
@@ -893,7 +893,7 @@ dnl so enable small net unless you really need this much support
 fi
 
 AC_ARG_WITH(nicklen,
-AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 15, max 50)]),
+AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 50, max 50)]),
 [
   if ! expr "$withval" + 0 >/dev/null 2>&1; then 
        AC_ERROR([NICKLEN must be a numeric value])
@@ -904,7 +904,7 @@ AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 1
   else
        NICKLEN="$withval"
   fi
-], [NICKLEN=15])
+], [NICKLEN=50])
 
 AC_ARG_WITH(topiclen,           
 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
index a365111466fc02706a23ee7c2253f48536e853ff..bbc44012c049681f2d873743edc909c3056d2861 100755 (executable)
@@ -80,6 +80,9 @@ serverinfo {
         *   /quote set maxclients <limit>
         */
        default_max_clients = 1024;
+
+       /* nicklen: enforced nickname length (for this server only; must be 50 or smaller) */
+       nicklen = 30;
 };
 
 admin {
index 91da8ff403592865c81c7289c4998e40c89a1730..332f5cea41af0b272ee43eedb314082d9d88b594 100755 (executable)
@@ -160,6 +160,9 @@ serverinfo {
         *   /quote set maxclients <limit>
         */
        default_max_clients = 1024;
+
+       /* nicklen: enforced nickname length (for this server only; must be 50 or smaller) */
+       nicklen = 30;
 };
 
 /* admin {}: contains admin information about the server. (OLD A:) */
index aa049a70836bb6cc9889c0208c6f2063bf8ee67a..8526f06c07936166c84d710eff8329cc17293481 100644 (file)
@@ -231,6 +231,7 @@ struct config_file_entry
        int client_flood_message_time;
        int client_flood_message_num;
 
+       unsigned int nicklen;
 };
 
 struct config_channel_entry
index 6361b2c6a36410cc3c945aed60cbfa746cecc7b1..0caa45966099ca5e213aa4ae20da4e465b6f9230 100644 (file)
@@ -138,7 +138,7 @@ mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
                *s = '\0';
 
        /* copy the nick and terminate it */
-       rb_strlcpy(nick, parv[1], sizeof(nick));
+       rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen);
 
        /* check the nickname is ok */
        if(!clean_nick(nick, 1))
@@ -201,7 +201,7 @@ m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *p
                flood_endgrace(source_p);
 
        /* terminate nick to NICKLEN, we dont want clean_nick() to error! */
-       rb_strlcpy(nick, parv[1], sizeof(nick));
+       rb_strlcpy(nick, parv[1], ConfigFileEntry.nicklen);
 
        /* check the nickname is ok */
        if(!clean_nick(nick, 1))
@@ -566,7 +566,7 @@ clean_nick(const char *nick, int loc_client)
        }
 
        /* nicklen is +1 */
-       if(len >= NICKLEN)
+       if(len >= NICKLEN && len >= ConfigFileEntry.nicklen)
                return 0;
 
        return 1;
index dd6eb82c7509da536c6ed3418ce41975ac4fe0e9..b7448a5b85f7ca6f7ac0f3b88ceb388201f4ae04 100644 (file)
@@ -653,7 +653,6 @@ main(int argc, char *argv[])
        init_reject();
        init_cache();
        init_monitor();
-       init_isupport();
 
         construct_cflags_strings();
 
@@ -674,6 +673,8 @@ main(int argc, char *argv[])
        mod_add_path(MODULE_DIR "/autoload"); 
 #endif
 
+       init_isupport();
+
        init_bandb();
        init_ssld();
 
index 95013c53601f7d7b7b054bd22eaef693d5423867..e5afd0ac76d1ef21e7fdb1a70587b6431585a37d 100644 (file)
@@ -260,6 +260,26 @@ conf_set_serverinfo_vhost6(void *data)
 #endif
 }
 
+static void
+conf_set_serverinfo_nicklen(void *data)
+{
+       static int nicklen_set = 0;
+
+       if (nicklen_set)
+               return;
+
+       ConfigFileEntry.nicklen = *(unsigned int *) data;
+
+       if (ConfigFileEntry.nicklen > NICKLEN)
+       {
+               conf_report_error("Warning -- ignoring serverinfo::nicklen -- provided nicklen (%u) is greater than allowed nicklen (%u)",
+                                 ConfigFileEntry.nicklen, NICKLEN);
+               ConfigFileEntry.nicklen = NICKLEN;
+       }
+
+       nicklen_set = 1;
+}
+
 static void
 conf_set_modules_module(void *data)
 {
@@ -2085,6 +2105,8 @@ static struct ConfEntry conf_serverinfo_table[] =
 
        { "default_max_clients",CF_INT,     NULL, 0, &ServerInfo.default_max_clients },
 
+       { "nicklen",            CF_INT,     conf_set_serverinfo_nicklen, 0, NULL },
+
        { "\0", 0, NULL, 0, NULL }
 };
 
index dd167c98bd53922a54f7c9a9833eacae0cad4e61..369522534ea68bcea0ac97130745d6473d93d42f 100644 (file)
@@ -801,6 +801,8 @@ set_default_conf(void)
 
        ServerInfo.default_max_clients = MAXCONNECTIONS;
 
+       ConfigFileEntry.nicklen = NICKLEN;
+
        if (!alias_dict)
                alias_dict = irc_dictionary_create(strcasecmp);
 }
index ff59396d2739b1b209bf0cfb9a8345b9c961dcf3..abe1d506eef78b3daa5f5146cb240586e40534f6 100644 (file)
@@ -292,9 +292,12 @@ void
 init_isupport(void)
 {
        static int maxmodes = MAXMODEPARAMS;
-       static int nicklen = NICKLEN-1;
        static int channellen = LOC_CHANNELLEN;
        static int topiclen = TOPICLEN;
+       static int nicklen = NICKLEN - 1;
+       static int nicklen_usable;
+
+       nicklen_usable = ConfigFileEntry.nicklen - 1;
 
        add_isupport("CHANTYPES", isupport_chantypes, NULL);
        add_isupport("EXCEPTS", isupport_boolean, &ConfigChannel.use_except);
@@ -311,6 +314,7 @@ init_isupport(void)
        add_isupport("CASEMAPPING", isupport_string, "rfc1459");
        add_isupport("CHARSET", isupport_string, "ascii");
        add_isupport("NICKLEN", isupport_intptr, &nicklen);
+       add_isupport("NICKLEN_USABLE", isupport_intptr, &nicklen_usable);
        add_isupport("CHANNELLEN", isupport_intptr, &channellen);
        add_isupport("TOPICLEN", isupport_intptr, &topiclen);
        add_isupport("ETRACE", isupport_string, "");