2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * Configuration management (reading, parsing & validation)
32 #include <sys/types.h>
52 static bool Use_Log = true, Using_MotdFile = true;
53 static CONF_SERVER New_Server;
54 static int New_Server_Idx;
56 static size_t Conf_Oper_Count;
57 static size_t Conf_Channel_Count;
58 static char Conf_MotdFile[FNAME_LEN];
60 static void Set_Defaults PARAMS(( bool InitServers ));
61 static bool Read_Config PARAMS(( bool ngircd_starting ));
62 static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash ));
64 static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg ));
65 static void Handle_FEATURES PARAMS(( int Line, char *Var, char *Arg ));
66 static void Handle_OPERATOR PARAMS(( int Line, char *Var, char *Arg ));
67 static void Handle_SERVER PARAMS(( int Line, char *Var, char *Arg ));
68 static void Handle_CHANNEL PARAMS(( int Line, char *Var, char *Arg ));
70 static void Config_Error PARAMS(( const int Level, const char *Format, ... ));
72 static void Config_Error_NaN PARAMS(( const int LINE, const char *Value ));
73 static void Config_Error_TooLong PARAMS(( const int LINE, const char *Value ));
75 static void Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
78 #define DEFAULT_LISTEN_ADDRSTR "::,0.0.0.0"
80 #define DEFAULT_LISTEN_ADDRSTR "0.0.0.0"
84 struct SSLOptions Conf_SSLOptions;
89 free(Conf_SSLOptions.KeyFile);
90 Conf_SSLOptions.KeyFile = NULL;
92 free(Conf_SSLOptions.CertFile);
93 Conf_SSLOptions.CertFile = NULL;
95 free(Conf_SSLOptions.DHFile);
96 Conf_SSLOptions.DHFile = NULL;
97 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
101 ssl_print_configvar(const char *name, const char *file)
106 printf(" %s =\n", name);
110 fp = fopen(file, "r");
114 fprintf(stderr, "ERROR: %s \"%s\": %s\n",
115 name, file, strerror(errno));
117 printf(" %s = %s\n", name, file);
126 ret = ssl_print_configvar("SSLKeyFile", Conf_SSLOptions.KeyFile);
128 if (!ssl_print_configvar("SSLCertFile", Conf_SSLOptions.CertFile))
131 if (!ssl_print_configvar("SSLDHFile", Conf_SSLOptions.DHFile))
134 if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
135 puts(" SSLKeyFilePassword = <secret>");
137 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
144 strdup_warn(const char *str)
146 char *ptr = strdup(str);
148 Config_Error(LOG_ERR, "Could not allocate mem for string: %s", str);
158 len = array_length(a, sizeof(UINT16));
160 ports = (UINT16*) array_start(a);
161 printf("%u", (unsigned int) *ports);
164 printf(", %u", (unsigned int) *ports);
172 ports_parse(array *a, int Line, char *Arg)
180 /* Ports on that the server should listen. More port numbers
181 * must be separated by "," */
182 ptr = strtok( Arg, "," );
186 if (port > 0 && port < 0xFFFF) {
187 port16 = (UINT16) port;
188 if (!array_catb(a, (char*)&port16, sizeof port16))
189 Config_Error(LOG_ERR, "%s, line %d Could not add port number %ld: %s",
190 NGIRCd_ConfFile, Line, port, strerror(errno));
192 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!",
193 NGIRCd_ConfFile, Line, port );
196 ptr = strtok( NULL, "," );
205 Validate_Config(false, false);
212 if (!Read_Config(false))
214 Validate_Config(false, true);
216 /* Update CLIENT structure of local server */
217 Client_SetInfo(Client_ThisServer(), Conf_ServerInfo);
219 } /* Config_Rehash */
223 yesno_to_str(int boolean_value)
234 struct Conf_Oper *op;
237 len = array_length(&Conf_Opers, sizeof(*op));
238 op = array_start(&Conf_Opers);
243 array_free(&Conf_Opers);
249 struct Conf_Oper *op;
252 len = array_length(&Conf_Opers, sizeof(*op));
253 op = array_start(&Conf_Opers);
258 printf(" Name = %s\n", op->name);
259 printf(" Password = %s\n", op->pwd);
260 printf(" Mask = %s\n\n", op->mask ? op->mask : "");
269 /* Read configuration, validate and output it. */
275 size_t predef_channel_count;
276 struct Conf_Channel *predef_chan;
280 if (! Read_Config(true))
283 config_valid = Validate_Config(true, false);
285 /* If stdin and stdout ("you can read our nice message and we can
286 * read in your keypress") are valid tty's, wait for a key: */
287 if( isatty( fileno( stdin )) && isatty( fileno( stdout ))) {
288 puts( "OK, press enter to see a dump of your service configuration ..." );
291 puts( "Ok, dump of your server configuration follows:\n" );
295 printf(" Name = %s\n", Conf_ServerName);
296 printf(" Info = %s\n", Conf_ServerInfo);
298 printf(" Password = %s\n", Conf_ServerPwd);
300 printf(" WebircPassword = %s\n", Conf_WebircPwd);
301 printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
302 printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
303 printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
304 if (Using_MotdFile) {
305 printf(" MotdFile = %s\n", Conf_MotdFile);
306 printf(" MotdPhrase =\n");
308 printf(" MotdFile = \n");
309 printf(" MotdPhrase = %s\n", array_bytes(&Conf_Motd)
310 ? (const char*) array_start(&Conf_Motd) : "");
312 printf(" ChrootDir = %s\n", Conf_Chroot);
313 printf(" PidFile = %s\n", Conf_PidFile);
314 printf(" Listen = %s\n", Conf_ListenAddress);
315 fputs(" Ports = ", stdout);
316 ports_puts(&Conf_ListenPorts);
318 fputs(" SSLPorts = ", stdout);
319 ports_puts(&Conf_SSLOptions.ListenPorts);
321 config_valid = false;
324 pwd = getpwuid(Conf_UID);
326 printf(" ServerUID = %s\n", pwd->pw_name);
328 printf(" ServerUID = %ld\n", (long)Conf_UID);
329 grp = getgrgid(Conf_GID);
331 printf(" ServerGID = %s\n", grp->gr_name);
333 printf(" ServerGID = %ld\n", (long)Conf_GID);
335 printf(" SyslogFacility = %s\n",
336 ngt_SyslogFacilityName(Conf_SyslogFacility));
338 printf(" PingTimeout = %d\n", Conf_PingTimeout);
339 printf(" PongTimeout = %d\n", Conf_PongTimeout);
340 printf(" ConnectRetry = %d\n", Conf_ConnectRetry);
341 printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
342 printf(" OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
343 printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
344 printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
346 printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
347 printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
349 printf(" MaxConnections = %ld\n", Conf_MaxConnections);
350 printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
351 printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
352 printf(" MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
355 printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
356 printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
357 printf(" PAM = %s\n", yesno_to_str(Conf_PAM));
358 printf(" ZeroConf = %s\n", yesno_to_str(Conf_ZeroConf));
363 for( i = 0; i < MAX_SERVERS; i++ ) {
364 if( ! Conf_Server[i].name[0] ) continue;
366 /* Valid "Server" section */
368 printf( " Name = %s\n", Conf_Server[i].name );
369 printf( " Host = %s\n", Conf_Server[i].host );
370 printf( " Port = %u\n", (unsigned int)Conf_Server[i].port );
372 printf( " SSLConnect = %s\n", Conf_Server[i].SSLConnect?"yes":"no");
374 printf( " MyPassword = %s\n", Conf_Server[i].pwd_in );
375 printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out );
376 printf( " ServiceMask = %s\n", Conf_Server[i].svs_mask);
377 printf( " Group = %d\n", Conf_Server[i].group );
378 printf( " Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
381 predef_channel_count = array_length(&Conf_Channels, sizeof(*predef_chan));
382 predef_chan = array_start(&Conf_Channels);
384 for (i = 0; i < predef_channel_count; i++, predef_chan++) {
385 if (!predef_chan->name[0])
388 /* Valid "Channel" section */
390 printf(" Name = %s\n", predef_chan->name);
391 printf(" Modes = %s\n", predef_chan->modes);
392 printf(" Key = %s\n", predef_chan->key);
393 printf(" MaxUsers = %lu\n", predef_chan->maxusers);
394 printf(" Topic = %s\n", predef_chan->topic);
395 printf(" KeyFile = %s\n\n", predef_chan->keyfile);
398 return (config_valid ? 0 : 1);
403 Conf_UnsetServer( CONN_ID Idx )
405 /* Set next time for next connection attempt, if this is a server
406 * link that is (still) configured here. If the server is set as
407 * "once", delete it from our configuration.
408 * Non-Server-Connections will be silently ignored. */
413 /* Check all our configured servers */
414 for( i = 0; i < MAX_SERVERS; i++ ) {
415 if( Conf_Server[i].conn_id != Idx ) continue;
417 /* Gotcha! Mark server configuration as "unused": */
418 Conf_Server[i].conn_id = NONE;
420 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
421 /* Delete configuration here */
422 Init_Server_Struct( &Conf_Server[i] );
424 /* Set time for next connect attempt */
426 if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
427 /* The connection has been "long", so we don't
428 * require the next attempt to be delayed. */
429 Conf_Server[i].lasttry =
430 t - Conf_ConnectRetry + RECONNECT_DELAY;
432 Conf_Server[i].lasttry = t;
435 } /* Conf_UnsetServer */
439 Conf_SetServer( int ConfServer, CONN_ID Idx )
441 /* Set connection for specified configured server */
443 assert( ConfServer > NONE );
444 assert( Idx > NONE );
446 Conf_Server[ConfServer].conn_id = Idx;
447 } /* Conf_SetServer */
451 Conf_GetServer( CONN_ID Idx )
453 /* Get index of server in configuration structure */
457 assert( Idx > NONE );
459 for( i = 0; i < MAX_SERVERS; i++ ) {
460 if( Conf_Server[i].conn_id == Idx ) return i;
463 } /* Conf_GetServer */
467 Conf_EnableServer( const char *Name, UINT16 Port )
469 /* Enable specified server and adjust port */
473 assert( Name != NULL );
475 for( i = 0; i < MAX_SERVERS; i++ ) {
476 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
477 /* Gotcha! Set port and enable server: */
478 Conf_Server[i].port = Port;
479 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
480 return (Conf_Server[i].port && Conf_Server[i].host[0]);
484 } /* Conf_EnableServer */
488 Conf_EnablePassiveServer(const char *Name)
490 /* Enable specified server */
493 assert( Name != NULL );
494 for (i = 0; i < MAX_SERVERS; i++) {
495 if ((strcasecmp( Conf_Server[i].name, Name ) == 0) && (Conf_Server[i].port > 0)) {
496 /* BINGO! Enable server */
497 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
502 } /* Conf_EnablePassiveServer */
506 Conf_DisableServer( const char *Name )
508 /* Enable specified server and adjust port */
512 assert( Name != NULL );
514 for( i = 0; i < MAX_SERVERS; i++ ) {
515 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
516 /* Gotcha! Disable and disconnect server: */
517 Conf_Server[i].flags |= CONF_SFLAG_DISABLED;
518 if( Conf_Server[i].conn_id > NONE ) Conn_Close( Conf_Server[i].conn_id, NULL, "Server link terminated on operator request", true);
523 } /* Conf_DisableServer */
527 Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )
529 /* Add new server to configuration */
533 assert( Name != NULL );
534 assert( Host != NULL );
535 assert( MyPwd != NULL );
536 assert( PeerPwd != NULL );
538 /* Search unused item in server configuration structure */
539 for( i = 0; i < MAX_SERVERS; i++ ) {
540 /* Is this item used? */
541 if( ! Conf_Server[i].name[0] ) break;
543 if( i >= MAX_SERVERS ) return false;
545 Init_Server_Struct( &Conf_Server[i] );
546 strlcpy( Conf_Server[i].name, Name, sizeof( Conf_Server[i].name ));
547 strlcpy( Conf_Server[i].host, Host, sizeof( Conf_Server[i].host ));
548 strlcpy( Conf_Server[i].pwd_out, MyPwd, sizeof( Conf_Server[i].pwd_out ));
549 strlcpy( Conf_Server[i].pwd_in, PeerPwd, sizeof( Conf_Server[i].pwd_in ));
550 Conf_Server[i].port = Port;
551 Conf_Server[i].flags = CONF_SFLAG_ONCE;
554 } /* Conf_AddServer */
558 * Check if the given nick name is an service
561 Conf_IsService(int ConfServer, const char *Nick)
563 return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
564 } /* Conf_IsService */
568 Set_Defaults_Optional(void)
581 Conf_ZeroConf = true;
583 Conf_ZeroConf = false;
589 * Initialize configuration settings with their default values.
592 Set_Defaults(bool InitServers)
596 strcpy(Conf_ServerName, "");
597 snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s",
598 PACKAGE_NAME, PACKAGE_VERSION);
599 strcpy(Conf_ServerPwd, "");
601 strcpy(Conf_ServerAdmin1, "");
602 strcpy(Conf_ServerAdmin2, "");
603 strcpy(Conf_ServerAdminMail, "");
605 strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile));
606 strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile));
608 Conf_UID = Conf_GID = 0;
609 strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
610 strlcpy(Conf_PidFile, PID_FILE, sizeof(Conf_PidFile));
612 free(Conf_ListenAddress);
613 Conf_ListenAddress = NULL;
615 Conf_PingTimeout = 120;
616 Conf_PongTimeout = 20;
617 Conf_ConnectRetry = 60;
621 Conf_Channel_Count = 0;
623 Conf_OperCanMode = false;
624 Conf_OperServerMode = false;
625 Conf_AllowRemoteOper = false;
626 Conf_PredefChannelsOnly = false;
628 Conf_ConnectIPv4 = true;
629 Conf_ConnectIPv6 = true;
631 Conf_MaxConnections = 0;
632 Conf_MaxConnectionsIP = 5;
634 Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
638 Conf_SyslogFacility = LOG_LOCAL5;
640 Conf_SyslogFacility = 0;
643 Set_Defaults_Optional();
645 /* Initialize server configuration structures */
647 for (i = 0; i < MAX_SERVERS;
648 Init_Server_Struct(&Conf_Server[i++]));
656 size_t cnt = array_bytes(&Conf_ListenPorts);
658 cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
664 Read_Motd(const char *filename)
669 if (*filename == '\0')
672 fp = fopen(filename, "r");
674 Log(LOG_WARNING, "Can't read MOTD file \"%s\": %s",
675 filename, strerror(errno));
679 array_free(&Conf_Motd);
680 Using_MotdFile = true;
682 while (fgets(line, (int)sizeof line, fp)) {
683 ngt_TrimLastChr( line, '\n');
685 /* add text including \0 */
686 if (!array_catb(&Conf_Motd, line, strlen(line) + 1)) {
687 Log(LOG_WARNING, "Cannot add MOTD text: %s", strerror(errno));
695 Read_Config( bool ngircd_starting )
697 /* Read configuration file. */
699 char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
700 const UINT16 defaultport = 6667;
704 /* Open configuration file */
705 fd = fopen( NGIRCd_ConfFile, "r" );
707 /* No configuration file found! */
708 Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s",
709 NGIRCd_ConfFile, strerror( errno ));
710 if (!ngircd_starting)
712 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
717 Set_Defaults( ngircd_starting );
719 Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
721 /* Clean up server configuration structure: mark all already
722 * configured servers as "once" so that they are deleted
723 * after the next disconnect and delete all unused servers.
724 * And delete all servers which are "duplicates" of servers
725 * that are already marked as "once" (such servers have been
726 * created by the last rehash but are now useless). */
727 for( i = 0; i < MAX_SERVERS; i++ ) {
728 if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
730 /* This structure is in use ... */
731 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
732 /* Check for duplicates */
733 for( n = 0; n < MAX_SERVERS; n++ ) {
734 if( n == i ) continue;
736 if( Conf_Server[i].conn_id == Conf_Server[n].conn_id ) {
737 Init_Server_Struct( &Conf_Server[n] );
739 Log(LOG_DEBUG,"Deleted unused duplicate server %d (kept %d).",
745 /* Mark server as "once" */
746 Conf_Server[i].flags |= CONF_SFLAG_ONCE;
747 Log( LOG_DEBUG, "Marked server %d as \"once\"", i );
752 /* Initialize variables */
754 strcpy( section, "" );
755 Init_Server_Struct( &New_Server );
756 New_Server_Idx = NONE;
760 /* Read configuration file */
762 if( ! fgets( str, LINE_LEN, fd )) break;
766 /* Skip comments and empty lines */
767 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
769 /* Is this the beginning of a new section? */
770 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' )) {
771 strlcpy( section, str, sizeof( section ));
772 if( strcasecmp( section, "[GLOBAL]" ) == 0 )
775 if( strcasecmp( section, "[SERVER]" ) == 0 ) {
776 /* Check if there is already a server to add */
777 if( New_Server.name[0] ) {
778 /* Copy data to "real" server structure */
779 assert( New_Server_Idx > NONE );
780 Conf_Server[New_Server_Idx] = New_Server;
783 /* Re-init structure for new server */
784 Init_Server_Struct( &New_Server );
786 /* Search unused item in server configuration structure */
787 for( i = 0; i < MAX_SERVERS; i++ ) {
788 /* Is this item used? */
789 if( ! Conf_Server[i].name[0] ) break;
791 if( i >= MAX_SERVERS ) {
792 /* Oops, no free item found! */
793 Config_Error( LOG_ERR, "Too many servers configured." );
794 New_Server_Idx = NONE;
796 else New_Server_Idx = i;
799 if (strcasecmp(section, "[CHANNEL]") == 0) {
800 Conf_Channel_Count++;
803 if (strcasecmp(section, "[OPERATOR]") == 0) {
808 Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
811 if( section[0] == 0x1 ) continue;
813 /* Split line into variable name and parameters */
814 ptr = strchr( str, '=' );
816 Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
820 var = str; ngt_TrimStr( var );
821 arg = ptr + 1; ngt_TrimStr( arg );
823 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
824 else if( strcasecmp( section, "[FEATURES]" ) == 0 ) Handle_FEATURES( line, var, arg );
825 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
826 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
827 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
828 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
831 /* Close configuration file */
834 /* Check if there is still a server to add */
835 if( New_Server.name[0] ) {
836 /* Copy data to "real" server structure */
837 assert( New_Server_Idx > NONE );
838 Conf_Server[New_Server_Idx] = New_Server;
841 /* not a single listening port? Add default. */
842 if (no_listenports() &&
843 !array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
845 Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
846 (unsigned int) defaultport, strerror(errno));
851 if (!Conf_ListenAddress)
852 Conf_ListenAddress = strdup_warn(DEFAULT_LISTEN_ADDRSTR);
854 if (!Conf_ListenAddress) {
855 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
859 /* No MOTD phrase configured? (re)try motd file. */
860 if (array_bytes(&Conf_Motd) == 0)
861 Read_Motd(Conf_MotdFile);
867 Check_ArgIsTrue( const char *Arg )
869 if( strcasecmp( Arg, "yes" ) == 0 ) return true;
870 if( strcasecmp( Arg, "true" ) == 0 ) return true;
871 if( atoi( Arg ) != 0 ) return true;
874 } /* Check_ArgIsTrue */
878 Handle_MaxNickLength(int Line, const char *Arg)
882 new = (unsigned) atoi(Arg) + 1;
883 if (new > CLIENT_NICK_LEN) {
884 Config_Error(LOG_WARNING,
885 "%s, line %d: Value of \"MaxNickLength\" exceeds %u!",
886 NGIRCd_ConfFile, Line, CLIENT_NICK_LEN - 1);
887 return CLIENT_NICK_LEN;
890 Config_Error(LOG_WARNING,
891 "%s, line %d: Value of \"MaxNickLength\" must be at least 1!",
892 NGIRCd_ConfFile, Line);
896 } /* Handle_MaxNickLength */
900 WarnIdent(int UNUSED Line)
904 /* user has enabled ident lookups explicitly, but ... */
905 Config_Error(LOG_WARNING,
906 "%s: line %d: %s=True, but ngircd was built without support",
907 NGIRCd_ConfFile, Line, "Ident");
913 WarnPAM(int UNUSED Line)
917 Config_Error(LOG_WARNING,
918 "%s: line %d: %s=True, but ngircd was built without support",
919 NGIRCd_ConfFile, Line, "PAM");
925 CheckLegacyNoOption(const char *Var, const char *Arg)
927 if( strcasecmp( Var, "NoDNS" ) == 0 ) {
928 Conf_DNS = !Check_ArgIsTrue( Arg );
931 if (strcasecmp(Var, "NoIdent") == 0) {
932 Conf_Ident = !Check_ArgIsTrue(Arg);
935 if(strcasecmp(Var, "NoPAM") == 0) {
936 Conf_PAM = !Check_ArgIsTrue(Arg);
939 if(strcasecmp(Var, "NoZeroConf") == 0) {
940 Conf_ZeroConf = !Check_ArgIsTrue(Arg);
947 NoNo(const char *str)
949 assert(strncasecmp("no", str, 2) == 0 && str[2]);
954 InvertArg(const char *arg)
956 return yesno_to_str(!Check_ArgIsTrue(arg));
960 Handle_GLOBAL( int Line, char *Var, char *Arg )
967 assert( Var != NULL );
968 assert( Arg != NULL );
970 if( strcasecmp( Var, "Name" ) == 0 ) {
972 len = strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName ));
973 if (len >= sizeof( Conf_ServerName ))
974 Config_Error_TooLong( Line, Var );
977 if( strcasecmp( Var, "Info" ) == 0 ) {
978 /* Info text of server */
979 len = strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo ));
980 if (len >= sizeof( Conf_ServerInfo ))
981 Config_Error_TooLong ( Line, Var );
984 if( strcasecmp( Var, "Password" ) == 0 ) {
985 /* Global server password */
986 len = strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd ));
987 if (len >= sizeof( Conf_ServerPwd ))
988 Config_Error_TooLong( Line, Var );
991 if (strcasecmp(Var, "WebircPassword") == 0) {
992 /* Password required for WEBIRC command */
993 len = strlcpy(Conf_WebircPwd, Arg, sizeof(Conf_WebircPwd));
994 if (len >= sizeof(Conf_WebircPwd))
995 Config_Error_TooLong(Line, Var);
998 if( strcasecmp( Var, "AdminInfo1" ) == 0 ) {
999 /* Administrative info #1 */
1000 len = strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 ));
1001 if (len >= sizeof( Conf_ServerAdmin1 ))
1002 Config_Error_TooLong ( Line, Var );
1005 if( strcasecmp( Var, "AdminInfo2" ) == 0 ) {
1006 /* Administrative info #2 */
1007 len = strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 ));
1008 if (len >= sizeof( Conf_ServerAdmin2 ))
1009 Config_Error_TooLong ( Line, Var );
1012 if( strcasecmp( Var, "AdminEMail" ) == 0 ) {
1013 /* Administrative email contact */
1014 len = strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail ));
1015 if (len >= sizeof( Conf_ServerAdminMail ))
1016 Config_Error_TooLong( Line, Var );
1020 if( strcasecmp( Var, "Ports" ) == 0 ) {
1021 ports_parse(&Conf_ListenPorts, Line, Arg);
1024 if( strcasecmp( Var, "MotdFile" ) == 0 ) {
1025 len = strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile ));
1026 if (len >= sizeof( Conf_MotdFile ))
1027 Config_Error_TooLong( Line, Var );
1031 if( strcasecmp( Var, "MotdPhrase" ) == 0 ) {
1032 /* "Message of the day" phrase (instead of file) */
1036 if (len >= LINE_LEN) {
1037 Config_Error_TooLong( Line, Var );
1040 if (!array_copyb(&Conf_Motd, Arg, len + 1))
1041 Config_Error(LOG_WARNING, "%s, line %d: Could not append MotdPhrase: %s",
1042 NGIRCd_ConfFile, Line, strerror(errno));
1043 Using_MotdFile = false;
1046 if( strcasecmp( Var, "ChrootDir" ) == 0 ) {
1047 /* directory for chroot() */
1048 len = strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot ));
1049 if (len >= sizeof( Conf_Chroot ))
1050 Config_Error_TooLong( Line, Var );
1053 if ( strcasecmp( Var, "PidFile" ) == 0 ) {
1054 /* name of pidfile */
1055 len = strlcpy( Conf_PidFile, Arg, sizeof( Conf_PidFile ));
1056 if (len >= sizeof( Conf_PidFile ))
1057 Config_Error_TooLong( Line, Var );
1060 if( strcasecmp( Var, "ServerUID" ) == 0 ) {
1061 /* UID the daemon should switch to */
1062 pwd = getpwnam( Arg );
1063 if( pwd ) Conf_UID = pwd->pw_uid;
1066 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1069 Conf_UID = (unsigned int)atoi( Arg );
1073 if( strcasecmp( Var, "ServerGID" ) == 0 ) {
1074 /* GID the daemon should use */
1075 grp = getgrnam( Arg );
1076 if( grp ) Conf_GID = grp->gr_gid;
1079 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1082 Conf_GID = (unsigned int)atoi( Arg );
1086 if( strcasecmp( Var, "PingTimeout" ) == 0 ) {
1088 Conf_PingTimeout = atoi( Arg );
1089 if( Conf_PingTimeout < 5 ) {
1090 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PingTimeout\" too low!",
1091 NGIRCd_ConfFile, Line );
1092 Conf_PingTimeout = 5;
1096 if( strcasecmp( Var, "PongTimeout" ) == 0 ) {
1098 Conf_PongTimeout = atoi( Arg );
1099 if( Conf_PongTimeout < 5 ) {
1100 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PongTimeout\" too low!",
1101 NGIRCd_ConfFile, Line );
1102 Conf_PongTimeout = 5;
1106 if( strcasecmp( Var, "ConnectRetry" ) == 0 ) {
1107 /* Seconds between connection attempts to other servers */
1108 Conf_ConnectRetry = atoi( Arg );
1109 if( Conf_ConnectRetry < 5 ) {
1110 Config_Error( LOG_WARNING, "%s, line %d: Value of \"ConnectRetry\" too low!",
1111 NGIRCd_ConfFile, Line );
1112 Conf_ConnectRetry = 5;
1116 if( strcasecmp( Var, "PredefChannelsOnly" ) == 0 ) {
1117 /* Should we only allow pre-defined-channels? (i.e. users cannot create their own channels) */
1118 Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
1122 if (CheckLegacyNoOption(Var, Arg)) {
1123 Config_Error(LOG_WARNING, "%s, line %d: \"No\"-Prefix has been removed, use "
1124 "\"%s = %s\" in [FEATURES] section instead",
1125 NGIRCd_ConfFile, Line, NoNo(Var), InvertArg(Arg));
1126 if (strcasecmp(Var, "NoIdent") == 0)
1128 else if (strcasecmp(Var, "NoPam") == 0)
1133 /* the default setting for all the WANT_IPV6 special options is 'true' */
1134 if( strcasecmp( Var, "ConnectIPv6" ) == 0 ) {
1135 /* connect to other hosts using ipv6, if they have an AAAA record? */
1136 Conf_ConnectIPv6 = Check_ArgIsTrue( Arg );
1139 if( strcasecmp( Var, "ConnectIPv4" ) == 0 ) {
1140 /* connect to other hosts using ipv4.
1141 * again, this can be used for ipv6-only setups */
1142 Conf_ConnectIPv4 = Check_ArgIsTrue( Arg );
1146 if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
1147 /* Are IRC operators allowed to use MODE in channels they aren't Op in? */
1148 Conf_OperCanMode = Check_ArgIsTrue( Arg );
1151 if( strcasecmp( Var, "OperServerMode" ) == 0 ) {
1152 /* Mask IRC operator as if coming from the server? (ircd-irc2 compat hack) */
1153 Conf_OperServerMode = Check_ArgIsTrue( Arg );
1156 if(strcasecmp(Var, "AllowRemoteOper") == 0) {
1157 /* Are remote IRC operators allowed to control this server? */
1158 Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
1161 if( strcasecmp( Var, "MaxConnections" ) == 0 ) {
1162 /* Maximum number of connections. 0 -> "no limit". */
1164 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var);
1167 Conf_MaxConnections = atol( Arg );
1170 if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 ) {
1171 /* Maximum number of simultaneous connections from one IP. 0 -> "no limit" */
1173 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1176 Conf_MaxConnectionsIP = atoi( Arg );
1179 if( strcasecmp( Var, "MaxJoins" ) == 0 ) {
1180 /* Maximum number of channels a user can join. 0 -> "no limit". */
1182 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1185 Conf_MaxJoins = atoi( Arg );
1188 if( strcasecmp( Var, "MaxNickLength" ) == 0 ) {
1189 /* Maximum length of a nick name; must be same on all servers
1190 * within the IRC network! */
1191 Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
1195 if( strcasecmp( Var, "Listen" ) == 0 ) {
1196 /* IP-Address to bind sockets */
1197 if (Conf_ListenAddress) {
1198 Config_Error(LOG_ERR, "Multiple Listen= options, ignoring: %s", Arg);
1201 Conf_ListenAddress = strdup_warn(Arg);
1203 * if allocation fails, we're in trouble:
1204 * we cannot ignore the error -- otherwise ngircd
1205 * would listen on all interfaces.
1207 if (!Conf_ListenAddress) {
1208 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
1215 if( strcasecmp( Var, "SSLPorts" ) == 0 ) {
1216 ports_parse(&Conf_SSLOptions.ListenPorts, Line, Arg);
1220 if( strcasecmp( Var, "SSLKeyFile" ) == 0 ) {
1221 assert(Conf_SSLOptions.KeyFile == NULL );
1222 Conf_SSLOptions.KeyFile = strdup_warn(Arg);
1225 if( strcasecmp( Var, "SSLCertFile" ) == 0 ) {
1226 assert(Conf_SSLOptions.CertFile == NULL );
1227 Conf_SSLOptions.CertFile = strdup_warn(Arg);
1231 if( strcasecmp( Var, "SSLKeyFilePassword" ) == 0 ) {
1232 assert(array_bytes(&Conf_SSLOptions.KeyFilePassword) == 0);
1233 if (!array_copys(&Conf_SSLOptions.KeyFilePassword, Arg))
1234 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Could not copy %s: %s!",
1235 NGIRCd_ConfFile, Line, Var, strerror(errno));
1238 if( strcasecmp( Var, "SSLDHFile" ) == 0 ) {
1239 assert(Conf_SSLOptions.DHFile == NULL);
1240 Conf_SSLOptions.DHFile = strdup_warn( Arg );
1245 if (strcasecmp(Var, "SyslogFacility") == 0) {
1246 Conf_SyslogFacility = ngt_SyslogFacilityID(Arg,
1247 Conf_SyslogFacility);
1251 Config_Error(LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!",
1252 NGIRCd_ConfFile, Line, Var);
1253 } /* Handle_GLOBAL */
1257 Handle_FEATURES(int Line, char *Var, char *Arg)
1260 assert( Var != NULL );
1261 assert( Arg != NULL );
1263 if( strcasecmp( Var, "DNS" ) == 0 ) {
1264 /* do reverse dns lookups when clients connect? */
1265 Conf_DNS = Check_ArgIsTrue( Arg );
1268 if (strcasecmp(Var, "Ident") == 0) {
1269 /* do IDENT lookups when clients connect? */
1270 Conf_Ident = Check_ArgIsTrue(Arg);
1274 if(strcasecmp(Var, "PAM") == 0) {
1275 /* use PAM library to authenticate users */
1276 Conf_PAM = Check_ArgIsTrue(Arg);
1280 if(strcasecmp(Var, "ZeroConf") == 0) {
1281 /* register services using ZeroConf */
1282 Conf_ZeroConf = Check_ArgIsTrue(Arg);
1288 Handle_OPERATOR( int Line, char *Var, char *Arg )
1291 struct Conf_Oper *op;
1294 assert( Var != NULL );
1295 assert( Arg != NULL );
1296 assert( Conf_Oper_Count > 0 );
1298 op = array_alloc(&Conf_Opers, sizeof(*op), Conf_Oper_Count - 1);
1300 Config_Error(LOG_ERR, "Could not allocate memory for operator (%d:%s = %s)", Line, Var, Arg);
1304 if (strcasecmp(Var, "Name") == 0) {
1305 /* Name of IRC operator */
1306 len = strlcpy(op->name, Arg, sizeof(op->name));
1307 if (len >= sizeof(op->name))
1308 Config_Error_TooLong(Line, Var);
1311 if (strcasecmp(Var, "Password") == 0) {
1312 /* Password of IRC operator */
1313 len = strlcpy(op->pwd, Arg, sizeof(op->pwd));
1314 if (len >= sizeof(op->pwd))
1315 Config_Error_TooLong(Line, Var);
1318 if (strcasecmp(Var, "Mask") == 0) {
1320 return; /* Hostname already configured */
1321 op->mask = strdup_warn( Arg );
1324 Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",
1325 NGIRCd_ConfFile, Line, Var );
1326 } /* Handle_OPERATOR */
1330 Handle_SERVER( int Line, char *Var, char *Arg )
1336 assert( Var != NULL );
1337 assert( Arg != NULL );
1339 /* Ignore server block if no space is left in server configuration structure */
1340 if( New_Server_Idx <= NONE ) return;
1342 if( strcasecmp( Var, "Host" ) == 0 ) {
1343 /* Hostname of the server */
1344 len = strlcpy( New_Server.host, Arg, sizeof( New_Server.host ));
1345 if (len >= sizeof( New_Server.host ))
1346 Config_Error_TooLong ( Line, Var );
1349 if( strcasecmp( Var, "Name" ) == 0 ) {
1350 /* Name of the server ("Nick"/"ID") */
1351 len = strlcpy( New_Server.name, Arg, sizeof( New_Server.name ));
1352 if (len >= sizeof( New_Server.name ))
1353 Config_Error_TooLong( Line, Var );
1356 if (strcasecmp(Var, "Bind") == 0) {
1357 if (ng_ipaddr_init(&New_Server.bind_addr, Arg, 0))
1360 Config_Error(LOG_ERR, "%s, line %d (section \"Server\"): Can't parse IP address \"%s\"",
1361 NGIRCd_ConfFile, Line, Arg);
1364 if( strcasecmp( Var, "MyPassword" ) == 0 ) {
1365 /* Password of this server which is sent to the peer */
1367 Config_Error(LOG_ERR,
1368 "%s, line %d (section \"Server\"): MyPassword must not start with ':'!",
1369 NGIRCd_ConfFile, Line);
1371 len = strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in ));
1372 if (len >= sizeof( New_Server.pwd_in ))
1373 Config_Error_TooLong( Line, Var );
1376 if( strcasecmp( Var, "PeerPassword" ) == 0 ) {
1377 /* Passwort of the peer which must be received */
1378 len = strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out ));
1379 if (len >= sizeof( New_Server.pwd_out ))
1380 Config_Error_TooLong( Line, Var );
1383 if( strcasecmp( Var, "Port" ) == 0 ) {
1384 /* Port to which this server should connect */
1386 if( port > 0 && port < 0xFFFF )
1387 New_Server.port = (UINT16)port;
1389 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!",
1390 NGIRCd_ConfFile, Line, port );
1394 if( strcasecmp( Var, "SSLConnect" ) == 0 ) {
1395 New_Server.SSLConnect = Check_ArgIsTrue(Arg);
1399 if( strcasecmp( Var, "Group" ) == 0 ) {
1402 if( ! isdigit( (int)*Arg ))
1403 Config_Error_NaN( Line, Var );
1406 New_Server.group = atoi( Arg );
1409 if( strcasecmp( Var, "Passive" ) == 0 ) {
1410 if (Check_ArgIsTrue(Arg))
1411 New_Server.flags |= CONF_SFLAG_DISABLED;
1414 if (strcasecmp(Var, "ServiceMask") == 0) {
1415 len = strlcpy(New_Server.svs_mask, ngt_LowerStr(Arg),
1416 sizeof(New_Server.svs_mask));
1417 if (len >= sizeof(New_Server.svs_mask))
1418 Config_Error_TooLong(Line, Var);
1422 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
1423 NGIRCd_ConfFile, Line, Var );
1424 } /* Handle_SERVER */
1428 Handle_Channelname(struct Conf_Channel *new_chan, const char *name)
1430 size_t size = sizeof(new_chan->name);
1431 char *dest = new_chan->name;
1433 if (!Channel_IsValidName(name)) {
1435 * maybe user forgot to add a '#'.
1436 * This is only here for user convenience.
1442 return size > strlcpy(dest, name, size);
1447 Handle_CHANNEL(int Line, char *Var, char *Arg)
1451 struct Conf_Channel *chan;
1454 assert( Var != NULL );
1455 assert( Arg != NULL );
1456 assert(Conf_Channel_Count > 0);
1458 chancount = Conf_Channel_Count - 1;
1460 chan = array_alloc(&Conf_Channels, sizeof(*chan), chancount);
1462 Config_Error(LOG_ERR, "Could not allocate memory for predefined channel (%d:%s = %s)", Line, Var, Arg);
1465 if (strcasecmp(Var, "Name") == 0) {
1466 if (!Handle_Channelname(chan, Arg))
1467 Config_Error_TooLong(Line, Var);
1470 if (strcasecmp(Var, "Modes") == 0) {
1472 len = strlcpy(chan->modes, Arg, sizeof(chan->modes));
1473 if (len >= sizeof(chan->modes))
1474 Config_Error_TooLong( Line, Var );
1477 if( strcasecmp( Var, "Topic" ) == 0 ) {
1479 len = strlcpy(chan->topic, Arg, sizeof(chan->topic));
1480 if (len >= sizeof(chan->topic))
1481 Config_Error_TooLong( Line, Var );
1484 if( strcasecmp( Var, "Key" ) == 0 ) {
1485 /* Initial Channel Key (mode k) */
1486 len = strlcpy(chan->key, Arg, sizeof(chan->key));
1487 if (len >= sizeof(chan->key))
1488 Config_Error_TooLong(Line, Var);
1491 if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
1492 /* maximum user limit, mode l */
1493 chan->maxusers = (unsigned long) atol(Arg);
1494 if (chan->maxusers == 0)
1495 Config_Error_NaN(Line, Var);
1498 if (strcasecmp(Var, "KeyFile") == 0) {
1500 len = strlcpy(chan->keyfile, Arg, sizeof(chan->keyfile));
1501 if (len >= sizeof(chan->keyfile))
1502 Config_Error_TooLong(Line, Var);
1506 Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
1507 NGIRCd_ConfFile, Line, Var );
1508 } /* Handle_CHANNEL */
1512 Validate_Config(bool Configtest, bool Rehash)
1514 /* Validate configuration settings. */
1517 int i, servers, servers_once;
1519 bool config_valid = true;
1522 /* Validate configured server name, see RFC 2812 section 2.3.1 */
1523 ptr = Conf_ServerName;
1525 if (*ptr >= 'a' && *ptr <= 'z') continue;
1526 if (*ptr >= 'A' && *ptr <= 'Z') continue;
1527 if (*ptr >= '0' && *ptr <= '9') continue;
1528 if (ptr > Conf_ServerName) {
1529 if (*ptr == '.' || *ptr == '-')
1532 Conf_ServerName[0] = '\0';
1536 if (!Conf_ServerName[0]) {
1537 /* No server name configured! */
1538 config_valid = false;
1539 Config_Error(LOG_ALERT,
1540 "No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
1542 if (!Configtest && !Rehash) {
1543 Config_Error(LOG_ALERT,
1544 "%s exiting due to fatal errors!",
1550 if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
1551 /* No dot in server name! */
1552 config_valid = false;
1553 Config_Error(LOG_ALERT,
1554 "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
1557 Config_Error(LOG_ALERT,
1558 "%s exiting due to fatal errors!",
1565 if (!Conf_ServerAdminMail[0]) {
1566 /* No administrative contact configured! */
1567 config_valid = false;
1568 Config_Error(LOG_ALERT,
1569 "No administrator email address configured in \"%s\" ('AdminEMail')!",
1572 Config_Error(LOG_ALERT,
1573 "%s exiting due to fatal errors!",
1580 if (!Conf_ServerAdmin1[0] && !Conf_ServerAdmin2[0]
1581 && !Conf_ServerAdminMail[0]) {
1582 /* No administrative information configured! */
1583 Config_Error(LOG_WARNING,
1584 "No administrative information configured but required by RFC!");
1588 if (Conf_ServerPwd[0])
1589 Config_Error(LOG_ERR,
1590 "This server uses PAM, \"Password\" will be ignored!");
1594 servers = servers_once = 0;
1595 for (i = 0; i < MAX_SERVERS; i++) {
1596 if (Conf_Server[i].name[0]) {
1598 if (Conf_Server[i].flags & CONF_SFLAG_ONCE)
1603 "Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
1604 Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
1607 return config_valid;
1608 } /* Validate_Config */
1612 Config_Error_TooLong ( const int Line, const char *Item )
1614 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" too long!", NGIRCd_ConfFile, Line, Item );
1619 Config_Error_NaN( const int Line, const char *Item )
1621 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" is not a number!",
1622 NGIRCd_ConfFile, Line, Item );
1627 static void Config_Error( const int Level, const char *Format, ... )
1629 static void Config_Error( Level, Format, va_alist )
1635 /* Error! Write to console and/or logfile. */
1637 char msg[MAX_LOG_MSG_LEN];
1640 assert( Format != NULL );
1643 va_start( ap, Format );
1647 vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
1650 /* During "normal operations" the log functions of the daemon should
1651 * be used, but during testing of the configuration file, all messages
1652 * should go directly to the console: */
1653 if (Use_Log) Log( Level, "%s", msg );
1655 } /* Config_Error */
1661 Conf_DebugDump(void)
1665 Log(LOG_DEBUG, "Configured servers:");
1666 for (i = 0; i < MAX_SERVERS; i++) {
1667 if (! Conf_Server[i].name[0])
1670 " - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
1671 Conf_Server[i].name, Conf_Server[i].host,
1672 Conf_Server[i].port, Conf_Server[i].lasttry,
1673 Conf_Server[i].group, Conf_Server[i].flags,
1674 Conf_Server[i].conn_id);
1676 } /* Conf_DebugDump */
1682 Init_Server_Struct( CONF_SERVER *Server )
1684 /* Initialize server configuration structur to default values */
1686 assert( Server != NULL );
1688 memset( Server, 0, sizeof (CONF_SERVER) );
1690 Server->group = NONE;
1691 Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
1693 if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
1695 Proc_InitStruct(&Server->res_stat);
1696 Server->conn_id = NONE;
1697 memset(&Server->bind_addr, 0, sizeof(&Server->bind_addr));
1698 } /* Init_Server_Struct */