about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2007-06-28 05:15:12 +0000
committerFlorian Westphal <fw@strlen.de>2007-06-28 05:15:12 +0000
commit2275add3271e2755775ab98510b8658402f79bc1 (patch)
tree765d39912230864b5c78b014a7bdd47a6bf8d869 /src
parentfd1091541bbfb3e6999ef8c818c853ea09939cac (diff)
downloadngircd-2275add3271e2755775ab98510b8658402f79bc1.tar.gz
ngircd-2275add3271e2755775ab98510b8658402f79bc1.zip
Add new server config option to disable automatic connect. (Tassilo Schweyer)
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conf.c28
-rw-r--r--src/ngircd/conf.h3
-rw-r--r--src/ngircd/irc-oper.c18
3 files changed, 41 insertions, 8 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index 05750f1f..0328f940 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -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++ ) {
@@ -337,6 +338,24 @@ Conf_EnableServer( char *Name, UINT16 Port )
 
 
 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 )
 {
 	/* Enable specified server and adjust port */
@@ -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 );
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
index 1f21b4b5..e927739d 100644
--- a/src/ngircd/conf.h
+++ b/src/ngircd/conf.h
@@ -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 ));
 
diff --git a/src/ngircd/irc-oper.c b/src/ngircd/irc-oper.c
index 1b301176..c80b8b05 100644
--- a/src/ngircd/irc-oper.c
+++ b/src/ngircd/irc-oper.c
@@ -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],