]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Added optional support for IDENT lookups (configure switch "--with-ident").
[ngircd-alex.git] / src / ngircd / conf.c
index 4cc78fe20bb99a1d373cde763cddc685db015891..81e0a916fe4c5c833dcd0848babbcb9265307661 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.54 2003/03/27 01:21:38 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.62 2003/12/19 14:32:59 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -108,7 +108,7 @@ Conf_Test( VOID )
        puts( "[GLOBAL]" );
        printf( "  ServerName = %s\n", Conf_ServerName );
        printf( "  ServerInfo = %s\n", Conf_ServerInfo );
-       printf( "  ServerPwd = %s\n", Conf_ServerPwd );
+       printf( "  Password = %s\n", Conf_ServerPwd );
        printf( "  AdminInfo1 = %s\n", Conf_ServerAdmin1 );
        printf( "  AdminInfo2 = %s\n", Conf_ServerAdmin2 );
        printf( "  AdminEMail = %s\n", Conf_ServerAdminMail );
@@ -120,6 +120,7 @@ Conf_Test( VOID )
                printf( "%u", Conf_ListenPorts[i] );
        }
        puts( "" );
+       printf( "  Listen = %s\n", Conf_ListenAddress );
        pwd = getpwuid( Conf_UID );
        if( pwd ) printf( "  ServerUID = %s\n", pwd->pw_name );
        else printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
@@ -132,6 +133,8 @@ Conf_Test( VOID )
        printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
        if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
        else printf( "  MaxConnections = -1\n" );
+       if( Conf_MaxConnectionsIP > 0 ) printf( "  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP );
+       else printf( "  MaxConnectionsIP = -1\n" );
        if( Conf_MaxJoins > 0 ) printf( "  MaxJoins = %d\n", Conf_MaxJoins );
        else printf( "  MaxJoins = -1\n" );
        puts( "" );
@@ -230,9 +233,9 @@ GLOBAL INT
 Conf_GetServer( CONN_ID Idx )
 {
        /* Get index of server in configuration structure */
-
-       INT i;
-
+       
+       INT i = 0;
+       
        assert( Idx > NONE );
 
        for( i = 0; i < MAX_SERVERS; i++ )
@@ -329,7 +332,7 @@ Set_Defaults( BOOLEAN InitServers )
        INT i;
 
        strcpy( Conf_ServerName, "" );
-       sprintf( Conf_ServerInfo, "%s %s", PACKAGEVERSION );
+       sprintf( Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
        strcpy( Conf_ServerPwd, "" );
 
        strcpy( Conf_ServerAdmin1, "" );
@@ -340,6 +343,7 @@ Set_Defaults( BOOLEAN InitServers )
        strlcat( Conf_MotdFile, MOTD_FILE, sizeof( Conf_MotdFile ));
 
        Conf_ListenPorts_Count = 0;
+       strcpy( Conf_ListenAddress, "" );
 
        Conf_UID = Conf_GID = 0;
        
@@ -354,6 +358,7 @@ Set_Defaults( BOOLEAN InitServers )
        Conf_OperCanMode = FALSE;
        
        Conf_MaxConnections = -1;
+       Conf_MaxConnectionsIP = 5;
        Conf_MaxJoins = 10;
 
        /* Initialize server configuration structures */
@@ -376,7 +381,7 @@ Read_Config( VOID )
        {
                /* No configuration file found! */
                Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
-               Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+               Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                exit( 1 );
        }
 
@@ -412,7 +417,7 @@ Read_Config( VOID )
                        {
                                /* Mark server as "once" */
                                Conf_Server[i].flags |= CONF_SFLAG_ONCE;
-                               Log( LOG_DEBUG, "Market server %d as \"once\"", i );
+                               Log( LOG_DEBUG, "Marked server %d as \"once\"", i );
                        }
                }
        }
@@ -689,6 +694,16 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
                Conf_MaxConnections = atol( Arg );
                return;
        }
+       if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 )
+       {
+               /* Maximum number of simoultanous connections from one IP. Values <= 0 are equal to "no limit". */
+#ifdef HAVE_ISDIGIT
+               if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnectionsIP\" is not a number!", NGIRCd_ConfFile, Line );
+               else
+#endif
+               Conf_MaxConnectionsIP = atoi( Arg );
+               return;
+       }
        if( strcasecmp( Var, "MaxJoins" ) == 0 )
        {
                /* Maximum number of channels a user can join. Values <= 0 are equal to "no limit". */
@@ -699,6 +714,15 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
                Conf_MaxJoins = atoi( Arg );
                return;
        }
+       if( strcasecmp( Var, "Listen" ) == 0 )
+       {
+               /* IP-Address to bind sockets */
+               if( strlcpy( Conf_ListenAddress, Arg, sizeof( Conf_ListenAddress )) >= sizeof( Conf_ListenAddress ))
+               {
+                       Config_Error( LOG_WARNING, "%s, line %d: Value of \"Listen\" too long!", NGIRCd_ConfFile, Line );
+               }
+               return;
+       }
 
        Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
 } /* Handle_GLOBAL */
@@ -830,10 +854,21 @@ Validate_Config( BOOLEAN Configtest )
        if( ! Conf_ServerName[0] )
        {
                /* No server name configured! */
-               Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
+               Config_Error( LOG_ALERT, "No server name configured in \"%s\" (section 'Global': 'Name')!", NGIRCd_ConfFile );
+               if( ! Configtest )
+               {
+                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
+                       exit( 1 );
+               }
+       }
+       
+       if( Conf_ServerName[0] && ! strchr( Conf_ServerName, '.' ))
+       {
+               /* No dot in server name! */
+               Config_Error( LOG_ALERT, "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!", NGIRCd_ConfFile );
                if( ! Configtest )
                {
-                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                        exit( 1 );
                }
        }
@@ -845,7 +880,7 @@ Validate_Config( BOOLEAN Configtest )
                Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
                if( ! Configtest )
                {
-                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                        exit( 1 );
                }
        }