]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Add new server config option to disable automatic connect. (Tassilo Schweyer)
authorFlorian Westphal <fw@strlen.de>
Thu, 28 Jun 2007 05:15:12 +0000 (05:15 +0000)
committerFlorian Westphal <fw@strlen.de>
Thu, 28 Jun 2007 05:15:12 +0000 (05:15 +0000)
ChangeLog
man/ngircd.conf.5.tmpl
src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/irc-oper.c

index 2d234e00918c98f1500a9fab69712d7dd5f1fdd9..87ecebd41bc1d46816e75408b4f8682703320a71 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@ ngIRCd HEAD
 
   - Fixed code that prevented GCC 2.95 to compile ngIRCd.
   - Adjust path names in manual pages according to "./configure" settings.
+  - Add new server config option to disable automatic connect. (Similar to -p
+    option to ngircd, but only for the specified server) (Tassilo Schweyer)
 
 ngIRCd 0.10.2 (2007-06-08)
 
@@ -694,4 +696,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.317 2007/06/13 14:32:13 alex Exp $
+$Id: ChangeLog,v 1.318 2007/06/28 05:15:12 fw Exp $
index ebdd9c956375c45c92f0e0eaa029bc414c82ffe3..b86302995fb4b8d851b7fa2d8011fd505f5ea134 100644 (file)
@@ -1,5 +1,5 @@
 .\"
-.\" $Id: ngircd.conf.5.tmpl,v 1.2 2006/12/29 14:09:49 fw Exp $
+.\" $Id: ngircd.conf.5.tmpl,v 1.3 2007/06/28 05:15:14 fw Exp $
 .\"
 .TH ngircd.conf 5 "August 2005" ngircd "ngIRCd Manual"
 .SH NAME
@@ -214,6 +214,9 @@ Foreign password for this connection. This password has to be configured as
 .TP
 \fBGroup\fR
 Group of this server (optional).
+\fBPassive\fR
+Disable automatic connection even if port value is specified. Default: false.
+You can use the IRC Operator command CONNECT later on to create the link.
 .SH [CHANNEL]
 Pre-defined channels can be configured in
 .I [Channel]
index 05750f1fc91e8feaad51635c3c2a0ab6d184cf93..0328f9402577c526060241852122ee9bd8ffc9b4 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.97 2006/12/29 14:09:50 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.98 2007/06/28 05:15:18 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -230,7 +230,8 @@ Conf_Test( void )
                printf( "  Port = %u\n", (unsigned int)Conf_Server[i].port );
                printf( "  MyPassword = %s\n", Conf_Server[i].pwd_in );
                printf( "  PeerPassword = %s\n", Conf_Server[i].pwd_out );
-               printf( "  Group = %d\n\n", Conf_Server[i].group );
+               printf( "  Group = %d\n", Conf_Server[i].group );
+               printf( "  Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
        }
 
        for( i = 0; i < Conf_Channel_Count; i++ ) {
@@ -336,6 +337,24 @@ Conf_EnableServer( char *Name, UINT16 Port )
 } /* Conf_EnableServer */
 
 
+GLOBAL bool
+Conf_EnablePassiveServer(const char *Name)
+{
+       /* Enable specified server */
+       int i;
+
+       assert( Name != NULL );
+       for (i = 0; i < MAX_SERVERS; i++) {
+               if ((strcasecmp( Conf_Server[i].name, Name ) == 0) && (Conf_Server[i].port > 0)) {
+                       /* BINGO! Enable server */
+                       Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
+                       return true;
+               }
+       }
+       return false;
+} /* Conf_EnablePassiveServer */
+
+
 GLOBAL bool
 Conf_DisableServer( char *Name )
 {
@@ -920,6 +939,11 @@ Handle_SERVER( int Line, char *Var, char *Arg )
                New_Server.group = atoi( Arg );
                return;
        }
+       if( strcasecmp( Var, "Passive" ) == 0 ) {
+               if (Check_ArgIsTrue(Arg))
+                       New_Server.flags |= CONF_SFLAG_DISABLED;
+               return;
+       }
        
        Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
                                                                NGIRCd_ConfFile, Line, Var );
index 1f21b4b52c06da42060f788e6ccd3610067cb607..e927739d791091a55d0e36408d157e8c39ba5f76 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.42 2006/12/29 14:09:50 fw Exp $
+ * $Id: conf.h,v 1.43 2007/06/28 05:15:18 fw Exp $
  *
  * Configuration management (header)
  */
@@ -142,6 +142,7 @@ GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
 GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx ));
 
 GLOBAL bool Conf_EnableServer PARAMS(( char *Name, UINT16 Port ));
+GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
 GLOBAL bool Conf_DisableServer PARAMS(( char *Name ));
 GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ));
 
index 1b3011761ceab4e4d0b646057144d75d10b2c9ce..c80b8b051aecc89b78848254bf99d6f58ccab6f4 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.27 2006/07/23 15:43:18 alex Exp $";
+static char UNUSED id[] = "$Id: irc-oper.c,v 1.28 2007/06/28 05:15:18 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -191,12 +191,12 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
                                          Client_ID(Client));
 
        /* Bad number of parameters? */
-       if ((Req->argc != 2) && (Req->argc != 5))
+       if ((Req->argc != 1) && (Req->argc != 2) && (Req->argc != 5))
                return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
                                          Client_ID(Client), Req->command);
 
        /* Invalid port number? */
-       if (atoi(Req->argv[1]) < 1)
+       if ((Req->argc > 1) && atoi(Req->argv[1]) < 1)
                return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
                                          Client_ID(Client), Req->command);
 
@@ -204,14 +204,22 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
            "Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client),
            Req->argv[0]);
 
-       if (Req->argc == 2) {
+       switch (Req->argc) {
+       case 1:
+               if (!Conf_EnablePassiveServer(Req->argv[0]))
+                       return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
+                                                 Client_ID(Client),
+                                                 Req->argv[0]);
+       break;
+       case 2:
                /* Connect configured server */
                if (!Conf_EnableServer
                    (Req->argv[0], (UINT16) atoi(Req->argv[1])))
                        return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
                                                  Client_ID(Client),
                                                  Req->argv[0]);
-       } else {
+       break;
+       default:
                /* Add server */
                if (!Conf_AddServer
                    (Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2],