add support for predefined-channel configuration of k and l modes

This commit is contained in:
Florian Westphal 2006-12-29 14:09:48 +00:00
parent 82aaffe55d
commit 1b852fce72
6 changed files with 47 additions and 8 deletions

View File

@ -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 $

View 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
@ -178,7 +178,13 @@
;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 ...

View 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
@ -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

View File

@ -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 )

View File

@ -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 */

View 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.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;