X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=c55aaf53a775f8945706a73305d3157ed277b623;hp=05750f1fc91e8feaad51635c3c2a0ab6d184cf93;hb=47ca178a219d682c589b27e64ee1a4e936cc7bdc;hpb=1b852fce72a87f3cce2049fde59ab66b6bbda6ca diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 05750f1f..c55aaf53 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.102 2007/11/21 12:16:36 alex Exp $"; #include "imp.h" #include @@ -205,9 +205,11 @@ Conf_Test( void ) 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; @@ -230,7 +232,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++ ) { @@ -336,6 +339,24 @@ Conf_EnableServer( char *Name, UINT16 Port ) } /* 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 ) { @@ -425,12 +446,14 @@ Set_Defaults( bool InitServers ) 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++] )); @@ -617,6 +640,27 @@ Check_ArgIsTrue( const char *Arg ) } /* 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 ) { @@ -764,6 +808,11 @@ 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 ); @@ -775,7 +824,7 @@ Handle_GLOBAL( int Line, char *Var, char *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 @@ -784,7 +833,7 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) 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 @@ -793,7 +842,7 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) 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 @@ -801,6 +850,13 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) 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 )); @@ -920,6 +976,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 );