/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2004 by Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "portab.h"
-static char UNUSED id[] = "$Id: ngircd.c,v 1.66 2002/12/26 13:17:57 alex Exp $";
+static char UNUSED id[] = "$Id: ngircd.c,v 1.81 2004/01/02 19:23:30 alex Exp $";
#include "imp.h"
#include <assert.h>
#include "parse.h"
#include "irc.h"
+#ifdef RENDEZVOUS
+#include "rendezvous.h"
+#endif
+
#include "exp.h"
#include "ngircd.h"
#ifdef SNIFFER
NGIRCd_Sniffer = FALSE;
#endif
- strcpy( NGIRCd_ConfFile, SYSCONFDIR );
- strcat( NGIRCd_ConfFile, CONFIG_FILE );
+ strlcpy( NGIRCd_ConfFile, SYSCONFDIR, sizeof( NGIRCd_ConfFile ));
+ strlcat( NGIRCd_ConfFile, CONFIG_FILE, sizeof( NGIRCd_ConfFile ));
/* Kommandozeile parsen */
for( i = 1; i < argc; i++ )
{
if( i + 1 < argc )
{
- /* Ok, danach kommt noch ein Parameter */
- strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 );
- NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
+ /* Ok, there's an parameter left */
+ strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
- /* zum uebernaechsten Parameter */
+ /* next parameter */
i++; ok = TRUE;
}
}
{
if(( ! argv[i][n + 1] ) && ( i + 1 < argc ))
{
- /* Ok, danach kommt ein Leerzeichen */
- strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 );
- NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
+ /* Ok, next character is a blank */
+ strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
- /* zum uebernaechsten Parameter */
+ /* go to the following parameter */
i++; n = (LONG)strlen( argv[i] );
ok = TRUE;
}
ok = TRUE;
}
#endif
+ if( argv[i][n] == 't' )
+ {
+ configtest = TRUE;
+ ok = TRUE;
+ }
if( ! ok )
{
- printf( "%s: invalid option \"-%c\"!\n", PACKAGE, argv[i][n] );
- printf( "Try \"%s --help\" for more information.\n", PACKAGE );
+ printf( "%s: invalid option \"-%c\"!\n", PACKAGE_NAME, argv[i][n] );
+ printf( "Try \"%s --help\" for more information.\n", PACKAGE_NAME );
exit( 1 );
}
}
}
if( ! ok )
{
- printf( "%s: invalid option \"%s\"!\n", PACKAGE, argv[i] );
- printf( "Try \"%s --help\" for more information.\n", PACKAGE );
+ printf( "%s: invalid option \"%s\"!\n", PACKAGE_NAME, argv[i] );
+ printf( "Try \"%s --help\" for more information.\n", PACKAGE_NAME );
exit( 1 );
}
}
if( pid < 0 )
{
/* Fehler */
- printf( "%s: Can't fork: %s!\nFatal error, exiting now ...\n", PACKAGE, strerror( errno ));
+ printf( "%s: Can't fork: %s!\nFatal error, exiting now ...\n", PACKAGE_NAME, strerror( errno ));
exit( 1 );
}
Lists_Init( );
Channel_Init( );
Client_Init( );
+#ifdef RENDEZVOUS
+ Rendezvous_Init( );
+#endif
Conn_Init( );
/* Wenn als root ausgefuehrt und eine andere UID
* beim PASS-Befehl verwendete Syntax sowie die erweiterten Flags
* sind in doc/Protocol.txt beschrieben. */
#ifdef IRCPLUS
- sprintf( NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE, VERSION, IRCPLUSFLAGS );
-#ifdef USE_ZLIB
+ sprintf( NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS );
+#ifdef ZLIB
strcat( NGIRCd_ProtoID, "Z" );
#endif
if( Conf_OperCanMode ) strcat( NGIRCd_ProtoID, "o" );
#else
- sprintf( NGIRCd_ProtoID, "%s%s %s|%s", PROTOVER, PROTOIRC, PACKAGE, VERSION );
+ sprintf( NGIRCd_ProtoID, "%s%s %s|%s", PROTOVER, PROTOIRC, PACKAGE_NAME, PACKAGE_VERSION );
#endif
strcat( NGIRCd_ProtoID, " P" );
-#ifdef USE_ZLIB
+#ifdef ZLIB
strcat( NGIRCd_ProtoID, "Z" );
#endif
Log( LOG_DEBUG, "Protocol and server ID is \"%s\".", NGIRCd_ProtoID );
if( Conn_InitListeners( ) < 1 )
{
Log( LOG_ALERT, "Server isn't listening on a single port!" );
- Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+ Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
exit( 1 );
}
/* Alles abmelden */
Conn_Exit( );
+#ifdef RENDEZVOUS
+ Rendezvous_Exit( );
+#endif
Client_Exit( );
Channel_Exit( );
Lists_Exit( );
STATIC CHAR version[126];
#ifdef CVSDATE
- sprintf( version, "%s %s(%s)-%s", PACKAGE, VERSION, CVSDATE, NGIRCd_VersionAddition( ));
+ sprintf( version, "%s %s(%s)-%s", PACKAGE_NAME, PACKAGE_VERSION, CVSDATE, NGIRCd_VersionAddition( ));
#else
- sprintf( version, "%s %s-%s", PACKAGE, VERSION, NGIRCd_VersionAddition( ));
+ sprintf( version, "%s %s-%s", PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition( ));
#endif
return version;
} /* NGIRCd_Version */
GLOBAL CHAR *
NGIRCd_VersionAddition( VOID )
{
- STATIC CHAR txt[64];
+ STATIC CHAR txt[200];
strcpy( txt, "" );
-#ifdef USE_SYSLOG
+#ifdef SYSLOG
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "SYSLOG" );
#endif
-#ifdef USE_ZLIB
+#ifdef ZLIB
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "ZLIB" );
#endif
+#ifdef TCPWRAP
+ if( txt[0] ) strcat( txt, "+" );
+ strcat( txt, "TCPWRAP" );
+#endif
+#ifdef RENDEZVOUS
+ if( txt[0] ) strcat( txt, "+" );
+ strcat( txt, "RENDEZVOUS" );
+#endif
+#ifdef IDENTAUTH
+ if( txt[0] ) strcat( txt, "+" );
+ strcat( txt, "IDENT" );
+#endif
#ifdef DEBUG
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "DEBUG" );
strcat( txt, "IRCPLUS" );
#endif
- if( txt[0] ) strcat( txt, "-" );
- strcat( txt, TARGET_CPU );
- strcat( txt, "/" );
- strcat( txt, TARGET_VENDOR );
- strcat( txt, "/" );
- strcat( txt, TARGET_OS );
+ if( txt[0] ) strlcat( txt, "-", sizeof( txt ));
+ strlcat( txt, TARGET_CPU, sizeof( txt ));
+ strlcat( txt, "/", sizeof( txt ));
+ strlcat( txt, TARGET_VENDOR, sizeof( txt ));
+ strlcat( txt, "/", sizeof( txt ));
+ strlcat( txt, TARGET_OS, sizeof( txt ));
return txt;
} /* NGIRCd_VersionAddition */
Conn_ExitListeners( );
/* Alten Server-Namen merken */
+#ifdef DEBUG
+ assert( sizeof( old_name ) == sizeof( Conf_ServerName ));
+#endif
strcpy( old_name, Conf_ServerName );
/* Konfiguration neu lesen ... */
- Conf_Init( );
+ Conf_Rehash( );
/* Alten Server-Namen wiederherstellen: dieser
* kann nicht zur Laufzeit geaendert werden ... */
/* Listen-Sockets neu anlegen: */
Conn_InitListeners( );
+ /* Sync configuration with established connections */
+ Conn_SyncServerStruct( );
+
Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." );
} /* NGIRCd_Rehash */
Show_Version( VOID )
{
puts( NGIRCd_Version( ));
- puts( "Copyright (c)2001,2002 by Alexander Barton (<alex@barton.de>)." );
+ puts( "Copyright (c)2001-2004 by Alexander Barton (<alex@barton.de>)." );
puts( "Homepage: <http://arthur.ath.cx/~alex/ngircd/>\n" );
puts( "This is free software; see the source for copying conditions. There is NO" );
puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
#ifdef SNIFFER
puts( " -s, --sniffer enable network sniffer and display all IRC traffic" );
#endif
- puts( " --configtest read, validate and display configuration; then exit" );
+ puts( " -t, --configtest read, validate and display configuration; then exit" );
puts( " --version output version information and exit" );
puts( " --help display this help and exit" );
} /* Show_Help */