Add support for customizing the usable nick length.

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.
This commit is contained in:
William Pitcock 2011-11-29 16:10:21 -06:00
parent e2606551a2
commit b583faf970
10 changed files with 46 additions and 9 deletions

5
configure vendored
View File

@ -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

View 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)]),

View File

@ -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 {

View File

@ -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:) */

View 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

View 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;

View 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();

View 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 }
};

View 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);
}

View 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, "");