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_OPERATOR PARAMS(( int Line, char *Var, char *Arg ));
66 static void Handle_SERVER PARAMS(( int Line, char *Var, char *Arg ));
67 static void Handle_CHANNEL PARAMS(( int Line, char *Var, char *Arg ));
69 static void Config_Error PARAMS(( const int Level, const char *Format, ... ));
71 static void Config_Error_NaN PARAMS(( const int LINE, const char *Value ));
72 static void Config_Error_TooLong PARAMS(( const int LINE, const char *Value ));
74 static void Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
77 #define DEFAULT_LISTEN_ADDRSTR "::,0.0.0.0"
79 #define DEFAULT_LISTEN_ADDRSTR "0.0.0.0"
83 struct SSLOptions Conf_SSLOptions;
88 free(Conf_SSLOptions.KeyFile);
89 Conf_SSLOptions.KeyFile = NULL;
91 free(Conf_SSLOptions.CertFile);
92 Conf_SSLOptions.CertFile = NULL;
94 free(Conf_SSLOptions.DHFile);
95 Conf_SSLOptions.DHFile = NULL;
96 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
100 ssl_print_configvar(const char *name, const char *file)
105 printf(" %s =\n", name);
109 fp = fopen(file, "r");
113 fprintf(stderr, "ERROR: %s \"%s\": %s\n",
114 name, file, strerror(errno));
116 printf(" %s = %s\n", name, file);
125 ret = ssl_print_configvar("SSLKeyFile", Conf_SSLOptions.KeyFile);
127 if (!ssl_print_configvar("SSLCertFile", Conf_SSLOptions.CertFile))
130 if (!ssl_print_configvar("SSLDHFile", Conf_SSLOptions.DHFile))
133 if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
134 puts(" SSLKeyFilePassword = <secret>");
136 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
143 strdup_warn(const char *str)
145 char *ptr = strdup(str);
147 Config_Error(LOG_ERR, "Could not allocate mem for string: %s", str);
157 len = array_length(a, sizeof(UINT16));
159 ports = (UINT16*) array_start(a);
160 printf("%u", (unsigned int) *ports);
163 printf(", %u", (unsigned int) *ports);
171 ports_parse(array *a, int Line, char *Arg)
179 /* Ports on that the server should listen. More port numbers
180 * must be separated by "," */
181 ptr = strtok( Arg, "," );
185 if (port > 0 && port < 0xFFFF) {
186 port16 = (UINT16) port;
187 if (!array_catb(a, (char*)&port16, sizeof port16))
188 Config_Error(LOG_ERR, "%s, line %d Could not add port number %ld: %s",
189 NGIRCd_ConfFile, Line, port, strerror(errno));
191 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!",
192 NGIRCd_ConfFile, Line, port );
195 ptr = strtok( NULL, "," );
204 Validate_Config(false, false);
211 if (!Read_Config(false))
213 Validate_Config(false, true);
215 /* Update CLIENT structure of local server */
216 Client_SetInfo(Client_ThisServer(), Conf_ServerInfo);
218 } /* Config_Rehash */
222 yesno_to_str(int boolean_value)
233 struct Conf_Oper *op;
236 len = array_length(&Conf_Opers, sizeof(*op));
237 op = array_start(&Conf_Opers);
242 array_free(&Conf_Opers);
248 struct Conf_Oper *op;
251 len = array_length(&Conf_Opers, sizeof(*op));
252 op = array_start(&Conf_Opers);
257 printf(" Name = %s\n", op->name);
258 printf(" Password = %s\n", op->pwd);
259 printf(" Mask = %s\n\n", op->mask ? op->mask : "");
268 /* Read configuration, validate and output it. */
274 size_t predef_channel_count;
275 struct Conf_Channel *predef_chan;
279 if (! Read_Config(true))
282 config_valid = Validate_Config(true, false);
284 /* If stdin and stdout ("you can read our nice message and we can
285 * read in your keypress") are valid tty's, wait for a key: */
286 if( isatty( fileno( stdin )) && isatty( fileno( stdout ))) {
287 puts( "OK, press enter to see a dump of your service configuration ..." );
290 puts( "Ok, dump of your server configuration follows:\n" );
294 printf(" Name = %s\n", Conf_ServerName);
295 printf(" Info = %s\n", Conf_ServerInfo);
297 printf(" Password = %s\n", Conf_ServerPwd);
299 printf(" WebircPassword = %s\n", Conf_WebircPwd);
300 printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
301 printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
302 printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
303 if (Using_MotdFile) {
304 printf(" MotdFile = %s\n", Conf_MotdFile);
305 printf(" MotdPhrase =\n");
307 printf(" MotdFile = \n");
308 printf(" MotdPhrase = %s\n", array_bytes(&Conf_Motd)
309 ? (const char*) array_start(&Conf_Motd) : "");
311 printf(" ChrootDir = %s\n", Conf_Chroot);
312 printf(" PidFile = %s\n", Conf_PidFile);
313 printf(" Listen = %s\n", Conf_ListenAddress);
314 fputs(" Ports = ", stdout);
315 ports_puts(&Conf_ListenPorts);
317 fputs(" SSLPorts = ", stdout);
318 ports_puts(&Conf_SSLOptions.ListenPorts);
320 config_valid = false;
323 pwd = getpwuid(Conf_UID);
325 printf(" ServerUID = %s\n", pwd->pw_name);
327 printf(" ServerUID = %ld\n", (long)Conf_UID);
328 grp = getgrgid(Conf_GID);
330 printf(" ServerGID = %s\n", grp->gr_name);
332 printf(" ServerGID = %ld\n", (long)Conf_GID);
334 printf(" SyslogFacility = %s\n",
335 ngt_SyslogFacilityName(Conf_SyslogFacility));
337 printf(" PingTimeout = %d\n", Conf_PingTimeout);
338 printf(" PongTimeout = %d\n", Conf_PongTimeout);
339 printf(" ConnectRetry = %d\n", Conf_ConnectRetry);
340 printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
341 printf(" OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
342 printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
343 printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
344 printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
345 printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
346 printf(" PAM = %s\n", yesno_to_str(Conf_PAM));
347 printf(" ZeroConf = %s\n", yesno_to_str(Conf_ZeroConf));
350 printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
351 printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
353 printf(" MaxConnections = %ld\n", Conf_MaxConnections);
354 printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
355 printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
356 printf(" MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
360 for( i = 0; i < MAX_SERVERS; i++ ) {
361 if( ! Conf_Server[i].name[0] ) continue;
363 /* Valid "Server" section */
365 printf( " Name = %s\n", Conf_Server[i].name );
366 printf( " Host = %s\n", Conf_Server[i].host );
367 printf( " Port = %u\n", (unsigned int)Conf_Server[i].port );
369 printf( " SSLConnect = %s\n", Conf_Server[i].SSLConnect?"yes":"no");
371 printf( " MyPassword = %s\n", Conf_Server[i].pwd_in );
372 printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out );
373 printf( " ServiceMask = %s\n", Conf_Server[i].svs_mask);
374 printf( " Group = %d\n", Conf_Server[i].group );
375 printf( " Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
378 predef_channel_count = array_length(&Conf_Channels, sizeof(*predef_chan));
379 predef_chan = array_start(&Conf_Channels);
381 for (i = 0; i < predef_channel_count; i++, predef_chan++) {
382 if (!predef_chan->name[0])
385 /* Valid "Channel" section */
387 printf(" Name = %s\n", predef_chan->name);
388 printf(" Modes = %s\n", predef_chan->modes);
389 printf(" Key = %s\n", predef_chan->key);
390 printf(" MaxUsers = %lu\n", predef_chan->maxusers);
391 printf(" Topic = %s\n", predef_chan->topic);
392 printf(" KeyFile = %s\n\n", predef_chan->keyfile);
395 return (config_valid ? 0 : 1);
400 Conf_UnsetServer( CONN_ID Idx )
402 /* Set next time for next connection attempt, if this is a server
403 * link that is (still) configured here. If the server is set as
404 * "once", delete it from our configuration.
405 * Non-Server-Connections will be silently ignored. */
410 /* Check all our configured servers */
411 for( i = 0; i < MAX_SERVERS; i++ ) {
412 if( Conf_Server[i].conn_id != Idx ) continue;
414 /* Gotcha! Mark server configuration as "unused": */
415 Conf_Server[i].conn_id = NONE;
417 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
418 /* Delete configuration here */
419 Init_Server_Struct( &Conf_Server[i] );
421 /* Set time for next connect attempt */
423 if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
424 /* The connection has been "long", so we don't
425 * require the next attempt to be delayed. */
426 Conf_Server[i].lasttry =
427 t - Conf_ConnectRetry + RECONNECT_DELAY;
429 Conf_Server[i].lasttry = t;
432 } /* Conf_UnsetServer */
436 Conf_SetServer( int ConfServer, CONN_ID Idx )
438 /* Set connection for specified configured server */
440 assert( ConfServer > NONE );
441 assert( Idx > NONE );
443 Conf_Server[ConfServer].conn_id = Idx;
444 } /* Conf_SetServer */
448 Conf_GetServer( CONN_ID Idx )
450 /* Get index of server in configuration structure */
454 assert( Idx > NONE );
456 for( i = 0; i < MAX_SERVERS; i++ ) {
457 if( Conf_Server[i].conn_id == Idx ) return i;
460 } /* Conf_GetServer */
464 Conf_EnableServer( const char *Name, UINT16 Port )
466 /* Enable specified server and adjust port */
470 assert( Name != NULL );
472 for( i = 0; i < MAX_SERVERS; i++ ) {
473 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
474 /* Gotcha! Set port and enable server: */
475 Conf_Server[i].port = Port;
476 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
477 return (Conf_Server[i].port && Conf_Server[i].host[0]);
481 } /* Conf_EnableServer */
485 Conf_EnablePassiveServer(const char *Name)
487 /* Enable specified server */
490 assert( Name != NULL );
491 for (i = 0; i < MAX_SERVERS; i++) {
492 if ((strcasecmp( Conf_Server[i].name, Name ) == 0) && (Conf_Server[i].port > 0)) {
493 /* BINGO! Enable server */
494 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
499 } /* Conf_EnablePassiveServer */
503 Conf_DisableServer( const char *Name )
505 /* Enable specified server and adjust port */
509 assert( Name != NULL );
511 for( i = 0; i < MAX_SERVERS; i++ ) {
512 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
513 /* Gotcha! Disable and disconnect server: */
514 Conf_Server[i].flags |= CONF_SFLAG_DISABLED;
515 if( Conf_Server[i].conn_id > NONE ) Conn_Close( Conf_Server[i].conn_id, NULL, "Server link terminated on operator request", true);
520 } /* Conf_DisableServer */
524 Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )
526 /* Add new server to configuration */
530 assert( Name != NULL );
531 assert( Host != NULL );
532 assert( MyPwd != NULL );
533 assert( PeerPwd != NULL );
535 /* Search unused item in server configuration structure */
536 for( i = 0; i < MAX_SERVERS; i++ ) {
537 /* Is this item used? */
538 if( ! Conf_Server[i].name[0] ) break;
540 if( i >= MAX_SERVERS ) return false;
542 Init_Server_Struct( &Conf_Server[i] );
543 strlcpy( Conf_Server[i].name, Name, sizeof( Conf_Server[i].name ));
544 strlcpy( Conf_Server[i].host, Host, sizeof( Conf_Server[i].host ));
545 strlcpy( Conf_Server[i].pwd_out, MyPwd, sizeof( Conf_Server[i].pwd_out ));
546 strlcpy( Conf_Server[i].pwd_in, PeerPwd, sizeof( Conf_Server[i].pwd_in ));
547 Conf_Server[i].port = Port;
548 Conf_Server[i].flags = CONF_SFLAG_ONCE;
551 } /* Conf_AddServer */
555 * Check if the given nick name is an service
558 Conf_IsService(int ConfServer, const char *Nick)
560 return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
561 } /* Conf_IsService */
565 Set_Defaults_Optional(void)
578 Conf_ZeroConf = true;
580 Conf_ZeroConf = false;
586 * Initialize configuration settings with their default values.
589 Set_Defaults(bool InitServers)
593 strcpy(Conf_ServerName, "");
594 snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s",
595 PACKAGE_NAME, PACKAGE_VERSION);
596 strcpy(Conf_ServerPwd, "");
598 strcpy(Conf_ServerAdmin1, "");
599 strcpy(Conf_ServerAdmin2, "");
600 strcpy(Conf_ServerAdminMail, "");
602 strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile));
603 strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile));
605 Conf_UID = Conf_GID = 0;
606 strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
607 strlcpy(Conf_PidFile, PID_FILE, sizeof(Conf_PidFile));
609 free(Conf_ListenAddress);
610 Conf_ListenAddress = NULL;
612 Conf_PingTimeout = 120;
613 Conf_PongTimeout = 20;
614 Conf_ConnectRetry = 60;
618 Conf_Channel_Count = 0;
620 Conf_OperCanMode = false;
621 Conf_OperServerMode = false;
622 Conf_AllowRemoteOper = false;
623 Conf_PredefChannelsOnly = false;
625 Conf_ConnectIPv4 = true;
626 Conf_ConnectIPv6 = true;
628 Conf_MaxConnections = 0;
629 Conf_MaxConnectionsIP = 5;
631 Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
635 Conf_SyslogFacility = LOG_LOCAL5;
637 Conf_SyslogFacility = 0;
640 Set_Defaults_Optional();
642 /* Initialize server configuration structures */
644 for (i = 0; i < MAX_SERVERS;
645 Init_Server_Struct(&Conf_Server[i++]));
653 size_t cnt = array_bytes(&Conf_ListenPorts);
655 cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
661 Read_Motd(const char *filename)
666 if (*filename == '\0')
669 fp = fopen(filename, "r");
671 Log(LOG_WARNING, "Can't read MOTD file \"%s\": %s",
672 filename, strerror(errno));
676 array_free(&Conf_Motd);
677 Using_MotdFile = true;
679 while (fgets(line, (int)sizeof line, fp)) {
680 ngt_TrimLastChr( line, '\n');
682 /* add text including \0 */
683 if (!array_catb(&Conf_Motd, line, strlen(line) + 1)) {
684 Log(LOG_WARNING, "Cannot add MOTD text: %s", strerror(errno));
692 Read_Config( bool ngircd_starting )
694 /* Read configuration file. */
696 char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
697 const UINT16 defaultport = 6667;
701 /* Open configuration file */
702 fd = fopen( NGIRCd_ConfFile, "r" );
704 /* No configuration file found! */
705 Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s",
706 NGIRCd_ConfFile, strerror( errno ));
707 if (!ngircd_starting)
709 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
714 Set_Defaults( ngircd_starting );
716 Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
718 /* Clean up server configuration structure: mark all already
719 * configured servers as "once" so that they are deleted
720 * after the next disconnect and delete all unused servers.
721 * And delete all servers which are "duplicates" of servers
722 * that are already marked as "once" (such servers have been
723 * created by the last rehash but are now useless). */
724 for( i = 0; i < MAX_SERVERS; i++ ) {
725 if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
727 /* This structure is in use ... */
728 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
729 /* Check for duplicates */
730 for( n = 0; n < MAX_SERVERS; n++ ) {
731 if( n == i ) continue;
733 if( Conf_Server[i].conn_id == Conf_Server[n].conn_id ) {
734 Init_Server_Struct( &Conf_Server[n] );
736 Log(LOG_DEBUG,"Deleted unused duplicate server %d (kept %d).",
742 /* Mark server as "once" */
743 Conf_Server[i].flags |= CONF_SFLAG_ONCE;
744 Log( LOG_DEBUG, "Marked server %d as \"once\"", i );
749 /* Initialize variables */
751 strcpy( section, "" );
752 Init_Server_Struct( &New_Server );
753 New_Server_Idx = NONE;
757 /* Read configuration file */
759 if( ! fgets( str, LINE_LEN, fd )) break;
763 /* Skip comments and empty lines */
764 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
766 /* Is this the beginning of a new section? */
767 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' )) {
768 strlcpy( section, str, sizeof( section ));
769 if( strcasecmp( section, "[GLOBAL]" ) == 0 )
772 if( strcasecmp( section, "[SERVER]" ) == 0 ) {
773 /* Check if there is already a server to add */
774 if( New_Server.name[0] ) {
775 /* Copy data to "real" server structure */
776 assert( New_Server_Idx > NONE );
777 Conf_Server[New_Server_Idx] = New_Server;
780 /* Re-init structure for new server */
781 Init_Server_Struct( &New_Server );
783 /* Search unused item in server configuration structure */
784 for( i = 0; i < MAX_SERVERS; i++ ) {
785 /* Is this item used? */
786 if( ! Conf_Server[i].name[0] ) break;
788 if( i >= MAX_SERVERS ) {
789 /* Oops, no free item found! */
790 Config_Error( LOG_ERR, "Too many servers configured." );
791 New_Server_Idx = NONE;
793 else New_Server_Idx = i;
796 if (strcasecmp(section, "[CHANNEL]") == 0) {
797 Conf_Channel_Count++;
800 if (strcasecmp(section, "[OPERATOR]") == 0) {
805 Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
808 if( section[0] == 0x1 ) continue;
810 /* Split line into variable name and parameters */
811 ptr = strchr( str, '=' );
813 Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
817 var = str; ngt_TrimStr( var );
818 arg = ptr + 1; ngt_TrimStr( arg );
820 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
821 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
822 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
823 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
824 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
827 /* Close configuration file */
830 /* Check if there is still a server to add */
831 if( New_Server.name[0] ) {
832 /* Copy data to "real" server structure */
833 assert( New_Server_Idx > NONE );
834 Conf_Server[New_Server_Idx] = New_Server;
837 /* not a single listening port? Add default. */
838 if (no_listenports() &&
839 !array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
841 Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
842 (unsigned int) defaultport, strerror(errno));
847 if (!Conf_ListenAddress)
848 Conf_ListenAddress = strdup_warn(DEFAULT_LISTEN_ADDRSTR);
850 if (!Conf_ListenAddress) {
851 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
855 /* No MOTD phrase configured? (re)try motd file. */
856 if (array_bytes(&Conf_Motd) == 0)
857 Read_Motd(Conf_MotdFile);
863 Check_ArgIsTrue( const char *Arg )
865 if( strcasecmp( Arg, "yes" ) == 0 ) return true;
866 if( strcasecmp( Arg, "true" ) == 0 ) return true;
867 if( atoi( Arg ) != 0 ) return true;
870 } /* Check_ArgIsTrue */
874 Handle_MaxNickLength(int Line, const char *Arg)
878 new = (unsigned) atoi(Arg) + 1;
879 if (new > CLIENT_NICK_LEN) {
880 Config_Error(LOG_WARNING,
881 "%s, line %d: Value of \"MaxNickLength\" exceeds %u!",
882 NGIRCd_ConfFile, Line, CLIENT_NICK_LEN - 1);
883 return CLIENT_NICK_LEN;
886 Config_Error(LOG_WARNING,
887 "%s, line %d: Value of \"MaxNickLength\" must be at least 1!",
888 NGIRCd_ConfFile, Line);
892 } /* Handle_MaxNickLength */
900 /* user has enabled ident lookups explicitly, but ... */
901 Config_Error(LOG_WARNING,
902 "%s: line %d: Ident=True, but ngircd was built without IDENT support",
903 NGIRCd_ConfFile, Line);
909 CheckLegacyNoOption(const char *Var, const char *Arg)
911 if( strcasecmp( Var, "NoDNS" ) == 0 ) {
912 Conf_DNS = !Check_ArgIsTrue( Arg );
915 if (strcasecmp(Var, "NoIdent") == 0) {
916 Conf_Ident = !Check_ArgIsTrue(Arg);
919 if(strcasecmp(Var, "NoPAM") == 0) {
920 Conf_PAM = !Check_ArgIsTrue(Arg);
923 if(strcasecmp(Var, "NoZeroConf") == 0) {
924 Conf_ZeroConf = !Check_ArgIsTrue(Arg);
931 NoNo(const char *str)
933 assert(strncasecmp("no", str, 2) == 0 && str[2]);
938 InvertArg(const char *arg)
940 return yesno_to_str(!Check_ArgIsTrue(arg));
944 Handle_GLOBAL( int Line, char *Var, char *Arg )
951 assert( Var != NULL );
952 assert( Arg != NULL );
954 if( strcasecmp( Var, "Name" ) == 0 ) {
956 len = strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName ));
957 if (len >= sizeof( Conf_ServerName ))
958 Config_Error_TooLong( Line, Var );
961 if( strcasecmp( Var, "Info" ) == 0 ) {
962 /* Info text of server */
963 len = strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo ));
964 if (len >= sizeof( Conf_ServerInfo ))
965 Config_Error_TooLong ( Line, Var );
968 if( strcasecmp( Var, "Password" ) == 0 ) {
969 /* Global server password */
970 len = strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd ));
971 if (len >= sizeof( Conf_ServerPwd ))
972 Config_Error_TooLong( Line, Var );
975 if (strcasecmp(Var, "WebircPassword") == 0) {
976 /* Password required for WEBIRC command */
977 len = strlcpy(Conf_WebircPwd, Arg, sizeof(Conf_WebircPwd));
978 if (len >= sizeof(Conf_WebircPwd))
979 Config_Error_TooLong(Line, Var);
982 if( strcasecmp( Var, "AdminInfo1" ) == 0 ) {
983 /* Administrative info #1 */
984 len = strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 ));
985 if (len >= sizeof( Conf_ServerAdmin1 ))
986 Config_Error_TooLong ( Line, Var );
989 if( strcasecmp( Var, "AdminInfo2" ) == 0 ) {
990 /* Administrative info #2 */
991 len = strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 ));
992 if (len >= sizeof( Conf_ServerAdmin2 ))
993 Config_Error_TooLong ( Line, Var );
996 if( strcasecmp( Var, "AdminEMail" ) == 0 ) {
997 /* Administrative email contact */
998 len = strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail ));
999 if (len >= sizeof( Conf_ServerAdminMail ))
1000 Config_Error_TooLong( Line, Var );
1004 if( strcasecmp( Var, "Ports" ) == 0 ) {
1005 ports_parse(&Conf_ListenPorts, Line, Arg);
1008 if( strcasecmp( Var, "MotdFile" ) == 0 ) {
1009 len = strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile ));
1010 if (len >= sizeof( Conf_MotdFile ))
1011 Config_Error_TooLong( Line, Var );
1015 if( strcasecmp( Var, "MotdPhrase" ) == 0 ) {
1016 /* "Message of the day" phrase (instead of file) */
1020 if (len >= LINE_LEN) {
1021 Config_Error_TooLong( Line, Var );
1024 if (!array_copyb(&Conf_Motd, Arg, len + 1))
1025 Config_Error(LOG_WARNING, "%s, line %d: Could not append MotdPhrase: %s",
1026 NGIRCd_ConfFile, Line, strerror(errno));
1027 Using_MotdFile = false;
1030 if( strcasecmp( Var, "ChrootDir" ) == 0 ) {
1031 /* directory for chroot() */
1032 len = strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot ));
1033 if (len >= sizeof( Conf_Chroot ))
1034 Config_Error_TooLong( Line, Var );
1037 if ( strcasecmp( Var, "PidFile" ) == 0 ) {
1038 /* name of pidfile */
1039 len = strlcpy( Conf_PidFile, Arg, sizeof( Conf_PidFile ));
1040 if (len >= sizeof( Conf_PidFile ))
1041 Config_Error_TooLong( Line, Var );
1044 if( strcasecmp( Var, "ServerUID" ) == 0 ) {
1045 /* UID the daemon should switch to */
1046 pwd = getpwnam( Arg );
1047 if( pwd ) Conf_UID = pwd->pw_uid;
1050 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1053 Conf_UID = (unsigned int)atoi( Arg );
1057 if( strcasecmp( Var, "ServerGID" ) == 0 ) {
1058 /* GID the daemon should use */
1059 grp = getgrnam( Arg );
1060 if( grp ) Conf_GID = grp->gr_gid;
1063 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1066 Conf_GID = (unsigned int)atoi( Arg );
1070 if( strcasecmp( Var, "PingTimeout" ) == 0 ) {
1072 Conf_PingTimeout = atoi( Arg );
1073 if( Conf_PingTimeout < 5 ) {
1074 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PingTimeout\" too low!",
1075 NGIRCd_ConfFile, Line );
1076 Conf_PingTimeout = 5;
1080 if( strcasecmp( Var, "PongTimeout" ) == 0 ) {
1082 Conf_PongTimeout = atoi( Arg );
1083 if( Conf_PongTimeout < 5 ) {
1084 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PongTimeout\" too low!",
1085 NGIRCd_ConfFile, Line );
1086 Conf_PongTimeout = 5;
1090 if( strcasecmp( Var, "ConnectRetry" ) == 0 ) {
1091 /* Seconds between connection attempts to other servers */
1092 Conf_ConnectRetry = atoi( Arg );
1093 if( Conf_ConnectRetry < 5 ) {
1094 Config_Error( LOG_WARNING, "%s, line %d: Value of \"ConnectRetry\" too low!",
1095 NGIRCd_ConfFile, Line );
1096 Conf_ConnectRetry = 5;
1100 if( strcasecmp( Var, "PredefChannelsOnly" ) == 0 ) {
1101 /* Should we only allow pre-defined-channels? (i.e. users cannot create their own channels) */
1102 Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
1106 if (CheckLegacyNoOption(Var, Arg)) {
1107 Config_Error(LOG_WARNING, "%s, line %d: \"No\"-Prefix has been removed, use "
1108 "\"%s = %s\" instead",
1109 NGIRCd_ConfFile, Line, NoNo(Var), InvertArg(Arg));
1110 if (strcasecmp(Var, "NoIdent") == 0)
1114 if( strcasecmp( Var, "DNS" ) == 0 ) {
1115 /* do reverse dns lookups when clients connect? */
1116 Conf_DNS = Check_ArgIsTrue( Arg );
1119 if (strcasecmp(Var, "Ident") == 0) {
1120 /* do IDENT lookups when clients connect? */
1121 Conf_Ident = Check_ArgIsTrue(Arg);
1125 if(strcasecmp(Var, "PAM") == 0) {
1126 /* use PAM library to authenticate users */
1127 Conf_PAM = Check_ArgIsTrue(Arg);
1130 if(strcasecmp(Var, "ZeroConf") == 0) {
1131 /* register services using ZeroConf */
1132 Conf_ZeroConf = Check_ArgIsTrue(Arg);
1136 /* the default setting for all the WANT_IPV6 special options is 'true' */
1137 if( strcasecmp( Var, "ConnectIPv6" ) == 0 ) {
1138 /* connect to other hosts using ipv6, if they have an AAAA record? */
1139 Conf_ConnectIPv6 = Check_ArgIsTrue( Arg );
1142 if( strcasecmp( Var, "ConnectIPv4" ) == 0 ) {
1143 /* connect to other hosts using ipv4.
1144 * again, this can be used for ipv6-only setups */
1145 Conf_ConnectIPv4 = Check_ArgIsTrue( Arg );
1149 if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
1150 /* Are IRC operators allowed to use MODE in channels they aren't Op in? */
1151 Conf_OperCanMode = Check_ArgIsTrue( Arg );
1154 if( strcasecmp( Var, "OperServerMode" ) == 0 ) {
1155 /* Mask IRC operator as if coming from the server? (ircd-irc2 compat hack) */
1156 Conf_OperServerMode = Check_ArgIsTrue( Arg );
1159 if(strcasecmp(Var, "AllowRemoteOper") == 0) {
1160 /* Are remote IRC operators allowed to control this server? */
1161 Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
1164 if( strcasecmp( Var, "MaxConnections" ) == 0 ) {
1165 /* Maximum number of connections. 0 -> "no limit". */
1167 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var);
1170 Conf_MaxConnections = atol( Arg );
1173 if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 ) {
1174 /* Maximum number of simultaneous connections from one IP. 0 -> "no limit" */
1176 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1179 Conf_MaxConnectionsIP = atoi( Arg );
1182 if( strcasecmp( Var, "MaxJoins" ) == 0 ) {
1183 /* Maximum number of channels a user can join. 0 -> "no limit". */
1185 if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var );
1188 Conf_MaxJoins = atoi( Arg );
1191 if( strcasecmp( Var, "MaxNickLength" ) == 0 ) {
1192 /* Maximum length of a nick name; must be same on all servers
1193 * within the IRC network! */
1194 Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
1198 if( strcasecmp( Var, "Listen" ) == 0 ) {
1199 /* IP-Address to bind sockets */
1200 if (Conf_ListenAddress) {
1201 Config_Error(LOG_ERR, "Multiple Listen= options, ignoring: %s", Arg);
1204 Conf_ListenAddress = strdup_warn(Arg);
1206 * if allocation fails, we're in trouble:
1207 * we cannot ignore the error -- otherwise ngircd
1208 * would listen on all interfaces.
1210 if (!Conf_ListenAddress) {
1211 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
1218 if( strcasecmp( Var, "SSLPorts" ) == 0 ) {
1219 ports_parse(&Conf_SSLOptions.ListenPorts, Line, Arg);
1223 if( strcasecmp( Var, "SSLKeyFile" ) == 0 ) {
1224 assert(Conf_SSLOptions.KeyFile == NULL );
1225 Conf_SSLOptions.KeyFile = strdup_warn(Arg);
1228 if( strcasecmp( Var, "SSLCertFile" ) == 0 ) {
1229 assert(Conf_SSLOptions.CertFile == NULL );
1230 Conf_SSLOptions.CertFile = strdup_warn(Arg);
1234 if( strcasecmp( Var, "SSLKeyFilePassword" ) == 0 ) {
1235 assert(array_bytes(&Conf_SSLOptions.KeyFilePassword) == 0);
1236 if (!array_copys(&Conf_SSLOptions.KeyFilePassword, Arg))
1237 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Could not copy %s: %s!",
1238 NGIRCd_ConfFile, Line, Var, strerror(errno));
1241 if( strcasecmp( Var, "SSLDHFile" ) == 0 ) {
1242 assert(Conf_SSLOptions.DHFile == NULL);
1243 Conf_SSLOptions.DHFile = strdup_warn( Arg );
1248 if (strcasecmp(Var, "SyslogFacility") == 0) {
1249 Conf_SyslogFacility = ngt_SyslogFacilityID(Arg,
1250 Conf_SyslogFacility);
1254 Config_Error(LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!",
1255 NGIRCd_ConfFile, Line, Var);
1256 } /* Handle_GLOBAL */
1260 Handle_OPERATOR( int Line, char *Var, char *Arg )
1263 struct Conf_Oper *op;
1266 assert( Var != NULL );
1267 assert( Arg != NULL );
1268 assert( Conf_Oper_Count > 0 );
1270 op = array_alloc(&Conf_Opers, sizeof(*op), Conf_Oper_Count - 1);
1272 Config_Error(LOG_ERR, "Could not allocate memory for operator (%d:%s = %s)", Line, Var, Arg);
1276 if (strcasecmp(Var, "Name") == 0) {
1277 /* Name of IRC operator */
1278 len = strlcpy(op->name, Arg, sizeof(op->name));
1279 if (len >= sizeof(op->name))
1280 Config_Error_TooLong(Line, Var);
1283 if (strcasecmp(Var, "Password") == 0) {
1284 /* Password of IRC operator */
1285 len = strlcpy(op->pwd, Arg, sizeof(op->pwd));
1286 if (len >= sizeof(op->pwd))
1287 Config_Error_TooLong(Line, Var);
1290 if (strcasecmp(Var, "Mask") == 0) {
1292 return; /* Hostname already configured */
1293 op->mask = strdup_warn( Arg );
1296 Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",
1297 NGIRCd_ConfFile, Line, Var );
1298 } /* Handle_OPERATOR */
1302 Handle_SERVER( int Line, char *Var, char *Arg )
1308 assert( Var != NULL );
1309 assert( Arg != NULL );
1311 /* Ignore server block if no space is left in server configuration structure */
1312 if( New_Server_Idx <= NONE ) return;
1314 if( strcasecmp( Var, "Host" ) == 0 ) {
1315 /* Hostname of the server */
1316 len = strlcpy( New_Server.host, Arg, sizeof( New_Server.host ));
1317 if (len >= sizeof( New_Server.host ))
1318 Config_Error_TooLong ( Line, Var );
1321 if( strcasecmp( Var, "Name" ) == 0 ) {
1322 /* Name of the server ("Nick"/"ID") */
1323 len = strlcpy( New_Server.name, Arg, sizeof( New_Server.name ));
1324 if (len >= sizeof( New_Server.name ))
1325 Config_Error_TooLong( Line, Var );
1328 if (strcasecmp(Var, "Bind") == 0) {
1329 if (ng_ipaddr_init(&New_Server.bind_addr, Arg, 0))
1332 Config_Error(LOG_ERR, "%s, line %d (section \"Server\"): Can't parse IP address \"%s\"",
1333 NGIRCd_ConfFile, Line, Arg);
1336 if( strcasecmp( Var, "MyPassword" ) == 0 ) {
1337 /* Password of this server which is sent to the peer */
1339 Config_Error(LOG_ERR,
1340 "%s, line %d (section \"Server\"): MyPassword must not start with ':'!",
1341 NGIRCd_ConfFile, Line);
1343 len = strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in ));
1344 if (len >= sizeof( New_Server.pwd_in ))
1345 Config_Error_TooLong( Line, Var );
1348 if( strcasecmp( Var, "PeerPassword" ) == 0 ) {
1349 /* Passwort of the peer which must be received */
1350 len = strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out ));
1351 if (len >= sizeof( New_Server.pwd_out ))
1352 Config_Error_TooLong( Line, Var );
1355 if( strcasecmp( Var, "Port" ) == 0 ) {
1356 /* Port to which this server should connect */
1358 if( port > 0 && port < 0xFFFF )
1359 New_Server.port = (UINT16)port;
1361 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!",
1362 NGIRCd_ConfFile, Line, port );
1366 if( strcasecmp( Var, "SSLConnect" ) == 0 ) {
1367 New_Server.SSLConnect = Check_ArgIsTrue(Arg);
1371 if( strcasecmp( Var, "Group" ) == 0 ) {
1374 if( ! isdigit( (int)*Arg ))
1375 Config_Error_NaN( Line, Var );
1378 New_Server.group = atoi( Arg );
1381 if( strcasecmp( Var, "Passive" ) == 0 ) {
1382 if (Check_ArgIsTrue(Arg))
1383 New_Server.flags |= CONF_SFLAG_DISABLED;
1386 if (strcasecmp(Var, "ServiceMask") == 0) {
1387 len = strlcpy(New_Server.svs_mask, ngt_LowerStr(Arg),
1388 sizeof(New_Server.svs_mask));
1389 if (len >= sizeof(New_Server.svs_mask))
1390 Config_Error_TooLong(Line, Var);
1394 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
1395 NGIRCd_ConfFile, Line, Var );
1396 } /* Handle_SERVER */
1400 Handle_Channelname(struct Conf_Channel *new_chan, const char *name)
1402 size_t size = sizeof(new_chan->name);
1403 char *dest = new_chan->name;
1405 if (!Channel_IsValidName(name)) {
1407 * maybe user forgot to add a '#'.
1408 * This is only here for user convenience.
1414 return size > strlcpy(dest, name, size);
1419 Handle_CHANNEL(int Line, char *Var, char *Arg)
1423 struct Conf_Channel *chan;
1426 assert( Var != NULL );
1427 assert( Arg != NULL );
1428 assert(Conf_Channel_Count > 0);
1430 chancount = Conf_Channel_Count - 1;
1432 chan = array_alloc(&Conf_Channels, sizeof(*chan), chancount);
1434 Config_Error(LOG_ERR, "Could not allocate memory for predefined channel (%d:%s = %s)", Line, Var, Arg);
1437 if (strcasecmp(Var, "Name") == 0) {
1438 if (!Handle_Channelname(chan, Arg))
1439 Config_Error_TooLong(Line, Var);
1442 if (strcasecmp(Var, "Modes") == 0) {
1444 len = strlcpy(chan->modes, Arg, sizeof(chan->modes));
1445 if (len >= sizeof(chan->modes))
1446 Config_Error_TooLong( Line, Var );
1449 if( strcasecmp( Var, "Topic" ) == 0 ) {
1451 len = strlcpy(chan->topic, Arg, sizeof(chan->topic));
1452 if (len >= sizeof(chan->topic))
1453 Config_Error_TooLong( Line, Var );
1456 if( strcasecmp( Var, "Key" ) == 0 ) {
1457 /* Initial Channel Key (mode k) */
1458 len = strlcpy(chan->key, Arg, sizeof(chan->key));
1459 if (len >= sizeof(chan->key))
1460 Config_Error_TooLong(Line, Var);
1463 if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
1464 /* maximum user limit, mode l */
1465 chan->maxusers = (unsigned long) atol(Arg);
1466 if (chan->maxusers == 0)
1467 Config_Error_NaN(Line, Var);
1470 if (strcasecmp(Var, "KeyFile") == 0) {
1472 len = strlcpy(chan->keyfile, Arg, sizeof(chan->keyfile));
1473 if (len >= sizeof(chan->keyfile))
1474 Config_Error_TooLong(Line, Var);
1478 Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
1479 NGIRCd_ConfFile, Line, Var );
1480 } /* Handle_CHANNEL */
1484 Validate_Config(bool Configtest, bool Rehash)
1486 /* Validate configuration settings. */
1489 int i, servers, servers_once;
1491 bool config_valid = true;
1494 /* Validate configured server name, see RFC 2812 section 2.3.1 */
1495 ptr = Conf_ServerName;
1497 if (*ptr >= 'a' && *ptr <= 'z') continue;
1498 if (*ptr >= 'A' && *ptr <= 'Z') continue;
1499 if (*ptr >= '0' && *ptr <= '9') continue;
1500 if (ptr > Conf_ServerName) {
1501 if (*ptr == '.' || *ptr == '-')
1504 Conf_ServerName[0] = '\0';
1508 if (!Conf_ServerName[0]) {
1509 /* No server name configured! */
1510 config_valid = false;
1511 Config_Error(LOG_ALERT,
1512 "No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
1514 if (!Configtest && !Rehash) {
1515 Config_Error(LOG_ALERT,
1516 "%s exiting due to fatal errors!",
1522 if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
1523 /* No dot in server name! */
1524 config_valid = false;
1525 Config_Error(LOG_ALERT,
1526 "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
1529 Config_Error(LOG_ALERT,
1530 "%s exiting due to fatal errors!",
1537 if (!Conf_ServerAdminMail[0]) {
1538 /* No administrative contact configured! */
1539 config_valid = false;
1540 Config_Error(LOG_ALERT,
1541 "No administrator email address configured in \"%s\" ('AdminEMail')!",
1544 Config_Error(LOG_ALERT,
1545 "%s exiting due to fatal errors!",
1552 if (!Conf_ServerAdmin1[0] && !Conf_ServerAdmin2[0]
1553 && !Conf_ServerAdminMail[0]) {
1554 /* No administrative information configured! */
1555 Config_Error(LOG_WARNING,
1556 "No administrative information configured but required by RFC!");
1560 if (Conf_ServerPwd[0])
1561 Config_Error(LOG_ERR,
1562 "This server uses PAM, \"Password\" will be ignored!");
1566 servers = servers_once = 0;
1567 for (i = 0; i < MAX_SERVERS; i++) {
1568 if (Conf_Server[i].name[0]) {
1570 if (Conf_Server[i].flags & CONF_SFLAG_ONCE)
1575 "Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
1576 Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
1579 return config_valid;
1580 } /* Validate_Config */
1584 Config_Error_TooLong ( const int Line, const char *Item )
1586 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" too long!", NGIRCd_ConfFile, Line, Item );
1591 Config_Error_NaN( const int Line, const char *Item )
1593 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" is not a number!",
1594 NGIRCd_ConfFile, Line, Item );
1599 static void Config_Error( const int Level, const char *Format, ... )
1601 static void Config_Error( Level, Format, va_alist )
1607 /* Error! Write to console and/or logfile. */
1609 char msg[MAX_LOG_MSG_LEN];
1612 assert( Format != NULL );
1615 va_start( ap, Format );
1619 vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
1622 /* During "normal operations" the log functions of the daemon should
1623 * be used, but during testing of the configuration file, all messages
1624 * should go directly to the console: */
1625 if (Use_Log) Log( Level, "%s", msg );
1627 } /* Config_Error */
1633 Conf_DebugDump(void)
1637 Log(LOG_DEBUG, "Configured servers:");
1638 for (i = 0; i < MAX_SERVERS; i++) {
1639 if (! Conf_Server[i].name[0])
1642 " - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
1643 Conf_Server[i].name, Conf_Server[i].host,
1644 Conf_Server[i].port, Conf_Server[i].lasttry,
1645 Conf_Server[i].group, Conf_Server[i].flags,
1646 Conf_Server[i].conn_id);
1648 } /* Conf_DebugDump */
1654 Init_Server_Struct( CONF_SERVER *Server )
1656 /* Initialize server configuration structur to default values */
1658 assert( Server != NULL );
1660 memset( Server, 0, sizeof (CONF_SERVER) );
1662 Server->group = NONE;
1663 Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
1665 if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
1667 Proc_InitStruct(&Server->res_stat);
1668 Server->conn_id = NONE;
1669 memset(&Server->bind_addr, 0, sizeof(&Server->bind_addr));
1670 } /* Init_Server_Struct */