]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Introduce option to configure the maximum nick name lenth in ngircd.conf
[ngircd-alex.git] / src / ngircd / conf.c
index 3c7b42d5063d7d90b8d260a308af9db1bef1f98b..c55aaf53a775f8945706a73305d3157ed277b623 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.100 2007/10/24 00:48:41 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.102 2007/11/21 12:16:36 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -205,9 +205,11 @@ Conf_Test( void )
        printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == true ? "yes" : "no" );
        printf( "  OperServerMode = %s\n", Conf_OperServerMode == true? "yes" : "no" );
        printf( "  PredefChannelsOnly = %s\n", Conf_PredefChannelsOnly == true ? "yes" : "no" );
+       printf( "  NoDNS = %s\n", Conf_NoDNS ? "yes" : "no");
        printf( "  MaxConnections = %ld\n", Conf_MaxConnections);
        printf( "  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
-       printf( "  MaxJoins = %d\n\n", Conf_MaxJoins);
+       printf( "  MaxJoins = %d\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1);
+       printf( "  MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
 
        for( i = 0; i < Conf_Oper_Count; i++ ) {
                if( ! Conf_Oper[i].name[0] ) continue;
@@ -444,12 +446,14 @@ Set_Defaults( bool InitServers )
        Conf_Channel_Count = 0;
 
        Conf_OperCanMode = false;
+       Conf_NoDNS = false;
        Conf_PredefChannelsOnly = false;
        Conf_OperServerMode = false;
 
        Conf_MaxConnections = 0;
        Conf_MaxConnectionsIP = 5;
        Conf_MaxJoins = 10;
+       Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
 
        /* Initialize server configuration structures */
        if( InitServers ) for( i = 0; i < MAX_SERVERS; Init_Server_Struct( &Conf_Server[i++] ));
@@ -636,6 +640,27 @@ Check_ArgIsTrue( const char *Arg )
 } /* Check_ArgIsTrue */
 
 
+static unsigned int Handle_MaxNickLength(int Line, const char *Arg)
+{
+       unsigned new;
+
+       new = (unsigned) atoi(Arg) + 1;
+       if (new > CLIENT_NICK_LEN) {
+               Config_Error(LOG_WARNING,
+                            "%s, line %d: Value of \"MaxNickLength\" exceeds %u!",
+                            NGIRCd_ConfFile, Line, CLIENT_NICK_LEN - 1);
+               return CLIENT_NICK_LEN;
+       }
+       if (new < 2) {
+               Config_Error(LOG_WARNING,
+                            "%s, line %d: Value of \"MaxNickLength\" must be at least 1!",
+                            NGIRCd_ConfFile, Line);
+               return 2;
+       }
+       return new;
+} /* Handle_MaxNickLength */
+
+
 static void
 Handle_GLOBAL( int Line, char *Var, char *Arg )
 {
@@ -783,6 +808,11 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
                Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
                return;
        }
+       if( strcasecmp( Var, "NoDNS" ) == 0 ) {
+               /* don't do reverse dns lookups when clients connect? */
+               Conf_NoDNS = Check_ArgIsTrue( Arg );
+               return;
+       }
        if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
                /* Are IRC operators allowed to use MODE in channels they aren't Op in? */
                Conf_OperCanMode = Check_ArgIsTrue( Arg );
@@ -820,6 +850,13 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
                Conf_MaxJoins = atoi( Arg );
                return;
        }
+       if( strcasecmp( Var, "MaxNickLength" ) == 0 ) {
+               /* Maximum length of a nick name; must be same on all servers
+                * within the IRC network! */
+               Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
+               return;
+       }
+
        if( strcasecmp( Var, "Listen" ) == 0 ) {
                /* IP-Address to bind sockets */
                len = strlcpy( Conf_ListenAddress, Arg, sizeof( Conf_ListenAddress ));