Commit Diff
Diff:
82aaffe55d6ed82465517a2f93a2d9e9a92b1f28
1b852fce72a87f3cce2049fde59ab66b6bbda6ca
Commit:
1b852fce72a87f3cce2049fde59ab66b6bbda6ca
Tree:
39c907530631cfefd60b221d6ec4218306c51811
Author:
Florian Westphal <fw@strlen.de>
Committer:
Florian Westphal <fw@strlen.de>
Date:
Fri Dec 29 14:09:48 2006 UTC
Message:
add support for predefined-channel configuration of k and l modes
blob - f723e2bcf516da90ad3c99989b7d0f691b7ec00b
blob + 50257bece5784b504044a29d602d56bdb471a63f
--- ChangeLog
+++ ChangeLog
@@ -12,6 +12,8 @@
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
@@ -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 $
blob - d5b971596822df52d61262c40669d0003a6d2712
blob + 6bed77b253cb52c689f07fbc3b2ea80897d3ac71
--- doc/sample-ngircd.conf
+++ doc/sample-ngircd.conf
@@ -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
@@ -178,8 +178,14 @@
;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 ...
blob - af32c411562701a18de5858ba68ce6572218d4ae
blob + ebdd9c956375c45c92f0e0eaa029bc414c82ffe3
--- man/ngircd.conf.5.tmpl
+++ man/ngircd.conf.5.tmpl
@@ -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
@@ -235,6 +235,12 @@ Topic for this channel
.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
blob - e31b268f509da533bbe888d65e9157fd817e78da
blob + 12b287c81eccef85857a2dcee35b28d1f848b30d
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -17,7 +17,7 @@
#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>
@@ -131,6 +131,9 @@ Channel_InitPredefined( void )
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 );
}
@@ -145,7 +148,7 @@ Channel_Exit( void )
{
CHANNEL *c, *c_next;
CL2CHAN *cl2chan, *cl2chan_next;
-
+
/* Channel-Strukturen freigeben */
c = My_Channels;
while( c )
blob - 7390f22477104d2c1c7e2f1ccc05493abb591c7e
blob + 05750f1fc91e8feaad51635c3c2a0ab6d184cf93
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -14,7 +14,7 @@
#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>
@@ -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 );
+ 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 : "");
@@ -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, "" );
+ 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++;
}
@@ -968,6 +972,22 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
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 */
blob - bb9a00b348f6d538c2a7a4fe3a90f8e43246878c
blob + 1f21b4b52c06da42060f788e6ccd3610067cb607
--- src/ngircd/conf.h
+++ 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.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)
*/
@@ -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 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;
IRCNow