]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Don't accept connections for servers already beeing linked
[ngircd-alex.git] / src / ngircd / conf.c
index 4ac37ad4033331e11692ee0aee6b87e96b6846ee..6a7f63393c6f7177f054b991e72a15009cf6fa1c 100644 (file)
@@ -350,6 +350,7 @@ Conf_Test( void )
        printf("  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
        printf("  MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
        printf("  MaxNickLength = %u\n", Conf_MaxNickLength - 1);
+       printf("  MaxListSize = %d\n", Conf_MaxListSize);
        printf("  PingTimeout = %d\n", Conf_PingTimeout);
        printf("  PongTimeout = %d\n", Conf_PongTimeout);
        puts("");
@@ -489,7 +490,7 @@ Conf_UnsetServer( CONN_ID Idx )
 /**
  * Set connection information for specified configured server.
  */
-GLOBAL void
+GLOBAL bool
 Conf_SetServer( int ConfServer, CONN_ID Idx )
 {
        assert( ConfServer > NONE );
@@ -497,13 +498,15 @@ Conf_SetServer( int ConfServer, CONN_ID Idx )
 
        if (Conf_Server[ConfServer].conn_id > NONE &&
            Conf_Server[ConfServer].conn_id != Idx) {
-               Log(LOG_ALERT,
-                       "Trying to update connection index for already registered server \"%s\": %d/%d - ignored.",
-                       Conf_Server[ConfServer].name,
-                       Conf_Server[ConfServer].conn_id, Idx);
-               return;
+               Log(LOG_ERR,
+                   "Connection %d: Server configuration of \"%s\" already in use by connection %d!",
+                   Idx, Conf_Server[ConfServer].name,
+                   Conf_Server[ConfServer].conn_id);
+               Conn_Close(Idx, NULL, "Server configuration already in use", true);
+               return false;
        }
        Conf_Server[ConfServer].conn_id = Idx;
+       return true;
 }
 
 /**
@@ -706,6 +709,7 @@ Set_Defaults(bool InitServers)
        Conf_MaxConnectionsIP = 5;
        Conf_MaxJoins = 10;
        Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
+       Conf_MaxListSize = 100;
        Conf_PingTimeout = 120;
        Conf_PongTimeout = 20;
 
@@ -1457,6 +1461,12 @@ Handle_LIMITS(int Line, char *Var, char *Arg)
                Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
                return;
        }
+       if (strcasecmp(Var, "MaxListSize") == 0) {
+               Conf_MaxListSize = atoi(Arg);
+               if (!Conf_MaxListSize && strcmp(Arg, "0"))
+                       Config_Error_NaN(Line, Var);
+               return;
+       }
        if (strcasecmp(Var, "PingTimeout") == 0) {
                Conf_PingTimeout = atoi(Arg);
                if (Conf_PingTimeout < 5) {