]> arthur.barton.de Git - ngircd-alex.git/commitdiff
add support for predefined-channel configuration of k and l modes
authorFlorian Westphal <fw@strlen.de>
Fri, 29 Dec 2006 14:09:48 +0000 (14:09 +0000)
committerFlorian Westphal <fw@strlen.de>
Fri, 29 Dec 2006 14:09:48 +0000 (14:09 +0000)
ChangeLog
doc/sample-ngircd.conf
man/ngircd.conf.5.tmpl
src/ngircd/channel.c
src/ngircd/conf.c
src/ngircd/conf.h

index f723e2bcf516da90ad3c99989b7d0f691b7ec00b..50257bece5784b504044a29d602d56bdb471a63f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
 
 ngIRCd HEAD
 
 
 ngIRCd HEAD
 
+  - Predefined Channel configuration now allows specification of channel key
+    (mode k) and maximum user count (mode l).
   - When using epoll() IO interface, compile in the select() interface as
     well and fall back to it when epoll() isn't available on runtime.
   - New configure option "--without-select" to disable select() IO API
   - When using epoll() IO interface, compile in the select() interface as
     well and fall back to it when epoll() isn't available on runtime.
   - New configure option "--without-select" to disable select() IO API
@@ -682,4 +684,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
 
 
 -- 
-$Id: ChangeLog,v 1.312 2006/12/26 16:00:45 alex Exp $
+$Id: ChangeLog,v 1.313 2006/12/29 14:09:48 fw Exp $
index d5b971596822df52d61262c40669d0003a6d2712..6bed77b253cb52c689f07fbc3b2ea80897d3ac71 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: sample-ngircd.conf,v 1.38 2006/11/05 13:03:47 fw Exp $
+# $Id: sample-ngircd.conf,v 1.39 2006/12/29 14:09:48 fw Exp $
 
 #
 # This is a sample configuration file for the ngIRCd, which must be adepted
 
 #
 # This is a sample configuration file for the ngIRCd, which must be adepted
        ;Topic = a great topic
 
        # Initial channel modes
        ;Topic = a great topic
 
        # Initial channel modes
-       ;Modes = tn
+       ;Modes = tnk
+
+       # initial channel password (mode k)
+       ;Key = Secret
+
+       # maximum users per channel (mode l)
+       ;MaxUsers = 23
 
 [Channel]
        # More [Channel] sections, if you like ...
 
 [Channel]
        # More [Channel] sections, if you like ...
index af32c411562701a18de5858ba68ce6572218d4ae..ebdd9c956375c45c92f0e0eaa029bc414c82ffe3 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\" $Id: ngircd.conf.5.tmpl,v 1.1 2006/12/25 16:13:26 alex Exp $
+.\" $Id: ngircd.conf.5.tmpl,v 1.2 2006/12/29 14:09:49 fw Exp $
 .\"
 .TH ngircd.conf 5 "August 2005" ngircd "ngIRCd Manual"
 .SH NAME
 .\"
 .TH ngircd.conf 5 "August 2005" ngircd "ngIRCd Manual"
 .SH NAME
@@ -235,6 +235,12 @@ Topic for this channel
 .TP
 \fBModes\fR
 Initial channel modes.
 .TP
 \fBModes\fR
 Initial channel modes.
+.TP
+\fBKey\fR
+Sets initial channel key (only relevant if mode k is set)
+.TP
+\fBMaxUsers\fR
+Set maximum user limit for this channel (only relevant if mode l is set)
 .SH HINTS
 It's wise to use "ngircd --configtest" to validate the configuration file
 after changing it. See
 .SH HINTS
 It's wise to use "ngircd --configtest" to validate the configuration file
 after changing it. See
index e31b268f509da533bbe888d65e9157fd817e78da..12b287c81eccef85857a2dcee35b28d1f848b30d 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "portab.h"
 
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.61 2006/12/07 22:23:39 fw Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.62 2006/12/29 14:09:50 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -131,6 +131,9 @@ Channel_InitPredefined( void )
                        while (*c)
                                Channel_ModeAdd(chan, *c++);
 
                        while (*c)
                                Channel_ModeAdd(chan, *c++);
 
+                       Channel_SetKey(chan, Conf_Channel[i].key);
+                       Channel_SetMaxUsers(chan, Conf_Channel[i].maxusers);
+
                        Log(LOG_INFO, "Created pre-defined channel \"%s\".",
                                                        Conf_Channel[i].name );
                }
                        Log(LOG_INFO, "Created pre-defined channel \"%s\".",
                                                        Conf_Channel[i].name );
                }
@@ -145,7 +148,7 @@ Channel_Exit( void )
 {
        CHANNEL *c, *c_next;
        CL2CHAN *cl2chan, *cl2chan_next;
 {
        CHANNEL *c, *c_next;
        CL2CHAN *cl2chan, *cl2chan_next;
-       
+
        /* Channel-Strukturen freigeben */
        c = My_Channels;
        while( c )
        /* Channel-Strukturen freigeben */
        c = My_Channels;
        while( c )
index 7390f22477104d2c1c7e2f1ccc05493abb591c7e..05750f1fc91e8feaad51635c3c2a0ab6d184cf93 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.96 2006/11/20 19:32:07 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.97 2006/12/29 14:09:50 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -240,6 +240,8 @@ Conf_Test( void )
                puts( "[CHANNEL]" );
                printf( "  Name = %s\n", Conf_Channel[i].name );
                printf( "  Modes = %s\n", Conf_Channel[i].modes );
                puts( "[CHANNEL]" );
                printf( "  Name = %s\n", Conf_Channel[i].name );
                printf( "  Modes = %s\n", Conf_Channel[i].modes );
+               printf( "  Key = %s\n", Conf_Channel[i].key );
+               printf( "  MaxUsers = %lu\n", Conf_Channel[i].maxusers );
 
                topic = (char*)array_start(&Conf_Channel[i].topic);
                printf( "  Topic = %s\n\n", topic ? topic : "");
 
                topic = (char*)array_start(&Conf_Channel[i].topic);
                printf( "  Topic = %s\n\n", topic ? topic : "");
@@ -555,6 +557,8 @@ Read_Config( void )
                                        /* Initialize new channel structure */
                                        strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
                                        strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
                                        /* Initialize new channel structure */
                                        strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
                                        strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
+                                       strcpy( Conf_Channel[Conf_Channel_Count].key, "" );
+                                       Conf_Channel[Conf_Channel_Count].maxusers = 0;
                                        array_free(&Conf_Channel[Conf_Channel_Count].topic);
                                        Conf_Channel_Count++;
                                }
                                        array_free(&Conf_Channel[Conf_Channel_Count].topic);
                                        Conf_Channel_Count++;
                                }
@@ -968,6 +972,22 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
                return;
        }
 
                return;
        }
 
+       if( strcasecmp( Var, "Key" ) == 0 ) {
+               /* Initial Channel Key (mode k) */
+               len = strlcpy(Conf_Channel[chancount].key, Arg, sizeof(Conf_Channel[chancount].key));
+               if (len >= sizeof( Conf_Channel[chancount].key ))
+                       Config_Error_TooLong(Line, Var);
+               return;
+       }
+
+       if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
+               /* maximum user limit, mode l */
+               Conf_Channel[chancount].maxusers = (unsigned long) atol(Arg);
+               if (Conf_Channel[chancount].maxusers == 0)
+                       Config_Error_NaN(Line, Var);
+               return;
+       }
+
        Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
                                                                NGIRCd_ConfFile, Line, Var );
 } /* Handle_CHANNEL */
        Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
                                                                NGIRCd_ConfFile, Line, Var );
 } /* Handle_CHANNEL */
index bb9a00b348f6d538c2a7a4fe3a90f8e43246878c..1f21b4b52c06da42060f788e6ccd3610067cb607 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.41 2006/11/05 13:03:48 fw Exp $
+ * $Id: conf.h,v 1.42 2006/12/29 14:09:50 fw Exp $
  *
  * Configuration management (header)
  */
  *
  * Configuration management (header)
  */
@@ -49,6 +49,8 @@ typedef struct _Conf_Channel
 {
        char name[CHANNEL_NAME_LEN];    /* Name of the channel */
        char modes[CHANNEL_MODE_LEN];   /* Initial channel modes */
 {
        char name[CHANNEL_NAME_LEN];    /* Name of the channel */
        char modes[CHANNEL_MODE_LEN];   /* Initial channel modes */
+       char key[CLIENT_PASS_LEN];      /* Channel key ("password", mode "k" ) */
+       unsigned long maxusers;         /* maximum usercount for this channel, mode "l" */
        array topic;                    /* Initial topic */
 } CONF_CHANNEL;
 
        array topic;                    /* Initial topic */
 } CONF_CHANNEL;