commit 29bd35bc4fa858f0ed36e39a3d00830859ce22c8 from: Alexander Barton date: Sun Feb 23 12:04:05 2003 UTC - Added optional support for Rendezvous. commit - f179070113dd04340b41b18efe9227dd5af40d99 commit + 29bd35bc4fa858f0ed36e39a3d00830859ce22c8 blob - 37c5c3819a49390a298bfcb80a33b7919595d1f8 blob + e3f88011b178731f8a2e4c70ab2d82e4dfd09622 --- src/ngircd/conn.c +++ src/ngircd/conn.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2003 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 @@ -16,7 +16,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conn.c,v 1.116 2003/02/21 19:19:27 alex Exp $"; +static char UNUSED id[] = "$Id: conn.c,v 1.117 2003/02/23 12:04:05 alex Exp $"; #include "imp.h" #include @@ -59,6 +59,10 @@ static char UNUSED id[] = "$Id: conn.c,v 1.116 2003/02 #include "parse.h" #include "tool.h" +#ifdef RENDEZVOUS +#include "rendezvous.h" +#endif + #include "exp.h" @@ -132,8 +136,13 @@ Conn_Exit( VOID ) CONN_ID idx; INT i; - /* Sockets schliessen */ Log( LOG_DEBUG, "Shutting down all connections ..." ); + +#ifdef RENDEZVOUS + Rendezvous_UnregisterListeners( ); +#endif + + /* Sockets schliessen */ for( i = 0; i < Conn_MaxFD + 1; i++ ) { if( FD_ISSET( i, &My_Sockets )) @@ -195,6 +204,10 @@ Conn_ExitListeners( VOID ) INT i; +#ifdef RENDEZVOUS + Rendezvous_UnregisterListeners( ); +#endif + Log( LOG_INFO, "Shutting down all listening sockets ..." ); for( i = 0; i < Conn_MaxFD + 1; i++ ) { @@ -214,7 +227,10 @@ Conn_NewListener( CONST UINT Port ) struct sockaddr_in addr; INT sock; - +#ifdef RENDEZVOUS + CHAR name[CLIENT_ID_LEN], *info; +#endif + /* Server-"Listen"-Socket initialisieren */ memset( &addr, 0, sizeof( addr )); addr.sin_family = AF_INET; @@ -254,7 +270,35 @@ Conn_NewListener( CONST UINT Port ) if( sock > Conn_MaxFD ) Conn_MaxFD = sock; Log( LOG_INFO, "Now listening on port %d (socket %d).", Port, sock ); + +#ifdef RENDEZVOUS + /* Get best server description text */ + if( ! Conf_ServerInfo[0] ) info = Conf_ServerName; + else + { + /* Use server info string */ + info = NULL; + if( Conf_ServerInfo[0] == '[' ) + { + /* Cut off leading hostname part in "[]" */ + info = strchr( Conf_ServerInfo, ']' ); + if( info ) + { + info++; + while( *info == ' ' ) info++; + } + } + if( ! info ) info = Conf_ServerInfo; + } + /* Add port number to description if non-standard */ + if( Port != 6667 ) snprintf( name, sizeof( name ), "%s (port %u)", info, Port ); + else strlcpy( name, info, sizeof( name )); + + /* Register service */ + Rendezvous_Register( name, RENDEZVOUS_TYPE, Port ); +#endif + return TRUE; } /* Conn_NewListener */ @@ -284,6 +328,10 @@ Conn_Handler( VOID ) while(( ! NGIRCd_SignalQuit ) && ( ! NGIRCd_SignalRestart )) { timeout = TRUE; + +#ifdef RENDEZVOUS + Rendezvous_Handler( ); +#endif /* Should the configuration be reloaded? */ if( NGIRCd_SignalRehash ) NGIRCd_Rehash( ); blob - e800117948347d4c61d3c118f22405303042da7d blob + 3b794b4a94df151fdb57a2aa710316df66d962b2 --- src/ngircd/ngircd.c +++ src/ngircd/ngircd.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: ngircd.c,v 1.71 2003/01/01 13:32:23 alex Exp $"; +static char UNUSED id[] = "$Id: ngircd.c,v 1.72 2003/02/23 12:04:05 alex Exp $"; #include "imp.h" #include @@ -42,6 +42,10 @@ static char UNUSED id[] = "$Id: ngircd.c,v 1.71 2003/0 #include "log.h" #include "parse.h" #include "irc.h" + +#ifdef RENDEZVOUS +#include "rendezvous.h" +#endif #include "exp.h" #include "ngircd.h" @@ -258,6 +262,9 @@ main( int argc, const char *argv[] ) Lists_Init( ); Channel_Init( ); Client_Init( ); +#ifdef RENDEZVOUS + Rendezvous_Init( ); +#endif Conn_Init( ); /* Wenn als root ausgefuehrt und eine andere UID @@ -320,6 +327,9 @@ main( int argc, const char *argv[] ) /* Alles abmelden */ Conn_Exit( ); +#ifdef RENDEZVOUS + Rendezvous_Exit( ); +#endif Client_Exit( ); Channel_Exit( ); Lists_Exit( ); @@ -375,6 +385,10 @@ NGIRCd_VersionAddition( VOID ) if( txt[0] ) strcat( txt, "+" ); strcat( txt, "IRCPLUS" ); #endif +#ifdef RENDEZVOUS + if( txt[0] ) strcat( txt, "+" ); + strcat( txt, "RENDEZVOUS" ); +#endif if( txt[0] ) strlcat( txt, "-", sizeof( txt )); strlcat( txt, TARGET_CPU, sizeof( txt ));