#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.103 2007/11/23 16:26:04 fw Exp $";
#include "imp.h"
#include <assert.h>
printf( " OperCanUseMode = %s\n", Conf_OperCanMode == true ? "yes" : "no" );
printf( " OperServerMode = %s\n", Conf_OperServerMode == true? "yes" : "no" );
printf( " PredefChannelsOnly = %s\n", Conf_PredefChannelsOnly == true ? "yes" : "no" );
- printf( " MaxConnections = %ld\n", Conf_MaxConnections>0 ? Conf_MaxConnections : -1);
- printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP>0 ? Conf_MaxConnectionsIP : -1);
- printf( " MaxJoins = %d\n\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1);
+ printf( " NoDNS = %s\n", Conf_NoDNS ? "yes" : "no");
+ printf( " MaxConnections = %ld\n", Conf_MaxConnections);
+ printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
+ printf( " MaxJoins = %d\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1);
+ printf( " MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
for( i = 0; i < Conf_Oper_Count; i++ ) {
if( ! Conf_Oper[i].name[0] ) continue;
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++ ) {
} /* 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 )
{
Conf_Channel_Count = 0;
Conf_OperCanMode = false;
+ Conf_NoDNS = false;
Conf_PredefChannelsOnly = false;
Conf_OperServerMode = false;
- Conf_MaxConnections = -1;
+ Conf_MaxConnections = 0;
Conf_MaxConnectionsIP = 5;
Conf_MaxJoins = 10;
+ Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
/* Initialize server configuration structures */
if( InitServers ) for( i = 0; i < MAX_SERVERS; Init_Server_Struct( &Conf_Server[i++] ));
} /* Check_ArgIsTrue */
+static unsigned int Handle_MaxNickLength(int Line, const char *Arg)
+{
+ unsigned new;
+
+ new = (unsigned) atoi(Arg) + 1;
+ if (new > CLIENT_NICK_LEN) {
+ Config_Error(LOG_WARNING,
+ "%s, line %d: Value of \"MaxNickLength\" exceeds %u!",
+ NGIRCd_ConfFile, Line, CLIENT_NICK_LEN - 1);
+ return CLIENT_NICK_LEN;
+ }
+ if (new < 2) {
+ Config_Error(LOG_WARNING,
+ "%s, line %d: Value of \"MaxNickLength\" must be at least 1!",
+ NGIRCd_ConfFile, Line);
+ return 2;
+ }
+ return new;
+} /* Handle_MaxNickLength */
+
+
static void
Handle_GLOBAL( int Line, char *Var, char *Arg )
{
Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
return;
}
+ if( strcasecmp( Var, "NoDNS" ) == 0 ) {
+ /* don't do reverse dns lookups when clients connect? */
+ Conf_NoDNS = Check_ArgIsTrue( Arg );
+ return;
+ }
if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
/* Are IRC operators allowed to use MODE in channels they aren't Op in? */
Conf_OperCanMode = Check_ArgIsTrue( Arg );
return;
}
if( strcasecmp( Var, "MaxConnections" ) == 0 ) {
- /* Maximum number of connections. Values <= 0 are equal to "no limit". */
+ /* Maximum number of connections. 0 -> "no limit". */
#ifdef HAVE_ISDIGIT
if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var);
else
return;
}
if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 ) {
- /* Maximum number of simultaneous connections from one IP. Values <= 0 -> "no limit" */
+ /* Maximum number of simultaneous connections from one IP. 0 -> "no limit" */
#ifdef HAVE_ISDIGIT
if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
else
return;
}
if( strcasecmp( Var, "MaxJoins" ) == 0 ) {
- /* Maximum number of channels a user can join. Values <= 0 are equal to "no limit". */
+ /* Maximum number of channels a user can join. 0 -> "no limit". */
#ifdef HAVE_ISDIGIT
if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
else
Conf_MaxJoins = atoi( Arg );
return;
}
+ if( strcasecmp( Var, "MaxNickLength" ) == 0 ) {
+ /* Maximum length of a nick name; must be same on all servers
+ * within the IRC network! */
+ Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
+ return;
+ }
+
if( strcasecmp( Var, "Listen" ) == 0 ) {
/* IP-Address to bind sockets */
len = strlcpy( Conf_ListenAddress, Arg, sizeof( Conf_ListenAddress ));
Config_Error_TooLong( Line, Var );
return;
}
+ if (strcasecmp(Var, "Bind") == 0) {
+ if (ngt_IPStrToBin(Arg, &New_Server.bind_addr))
+ return;
+
+ Config_Error(LOG_ERR, "%s, line %d (section \"Server\"): Can't parse IP address \"%s\"",
+ NGIRCd_ConfFile, Line, Arg);
+ return;
+ }
if( strcasecmp( Var, "MyPassword" ) == 0 ) {
/* Password of this server which is sent to the peer */
if (*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 );
Resolve_Init(&Server->res_stat);
Server->conn_id = NONE;
+ Server->bind_addr.s_addr = htonl(INADDR_ANY);
} /* Init_Server_Struct */