ChangeLog | 14 +++++- NEWS | 5 ++ configure.in | 15 ++++-- contrib/Debian/changelog | 8 +++- contrib/MacOSX/ngIRCd.pmdoc/index.xml | 4 +- contrib/ngircd.spec | 2 +- doc/Platforms.txt | 14 +++-- src/ngircd/conn.c | 95 ++++++++++++++++++++++++-------- src/ngircd/conn.h | 6 ++- src/ngircd/irc-info.c | 6 ++- src/ngircd/log.c | 4 +- src/ngircd/messages.h | 1 + src/ngircd/ngircd.c | 8 ++- src/ngircd/resolve.c | 8 ++-- 14 files changed, 140 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 878eb25..55b0c39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ ngIRCd - Next Generation IRC Server - (c)2001-2009 Alexander Barton, + (c)2001-2010 Alexander Barton, alex@barton.de, http://www.barton.de/ ngIRCd is free software and published under the @@ -12,6 +12,18 @@ ngIRCd Release 16 + ngIRCd 16~rc2 (2010-04-25) + - Updated some more copyright notices, it's 2010 already :-) + - Only compile in Get_Error() if really needed + - Fix gcc warning "ignoring return value of ..." + - Include netinet/in_systm.h alongside netinet/ip.h + - Include netinet/{in.h, in_systm.h} when checking for netinet/ip.h + - Only include if it exists + - Updated doc/Platforms.txt + - Enhace connection statistics counters: display total number of served + connections on daemon shutdown and when a new client connects using + the new numeric RPL_STATSCONN (250). + ngIRCd 16~rc1 (2010-03-25) - Various fixes to the build system and code cleanups. - contrib/platformtest.sh: Only show latest commit. diff --git a/NEWS b/NEWS index 7c6f948..71f9f60 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,11 @@ ngIRCd Release 16 + ngIRCd 16~rc2 (2010-04-25) + - Enhace connection statistics counters: display total number of served + connections on daemon shutdown and when a new client connects using + the new numeric RPL_STATSCONN (250). + ngIRCd 16~rc1 (2010-03-25) - Implement WEBIRC command used by some Web-IRC frontends. The password required to secure this command must be configured using the new diff --git a/configure.in b/configure.in index 153ec57..112bad3 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ # -- Initialisation -- AC_PREREQ(2.50) -AC_INIT(ngircd, 16~rc1) +AC_INIT(ngircd, 16~rc2) AC_CONFIG_SRCDIR(src/ngircd/ngircd.c) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(1.6) @@ -101,12 +101,19 @@ AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([ \ - ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \ - strings.h sys/socket.h sys/time.h unistd.h \ + ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \ + stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \ ],,AC_MSG_ERROR([required C header missing!])) AC_CHECK_HEADERS([ \ - arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h]) + arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \ + ],[],[],[[ + #include + #ifdef HAVE_NETINET_IN_SYSTM_H + #include + #endif + ]] +) # -- Datatypes -- diff --git a/contrib/Debian/changelog b/contrib/Debian/changelog index 4bab648..9da2f18 100644 --- a/contrib/Debian/changelog +++ b/contrib/Debian/changelog @@ -1,8 +1,14 @@ +ngircd (16~rc2-0ab1) unstable; urgency=low + + * New "upstream" release candidate 2 for ngIRCd Release 16. + + -- Alexander Barton Sun, 25 Apr 2010 13:12:42 +0200 + ngircd (16~rc1-0ab1) unstable; urgency=low * New "upstream" release candidate 1 for ngIRCd Release 16. - -- Alexander Barton Thu, 25 Mar 2010 15:56:03 +0100 + -- Alexander Barton Thu, 25 Mar 2010 15:56:03 +0200 ngircd (15-0ab1) unstable; urgency=low diff --git a/contrib/MacOSX/ngIRCd.pmdoc/index.xml b/contrib/MacOSX/ngIRCd.pmdoc/index.xml index 2881d58..5d6b8e3 100644 --- a/contrib/MacOSX/ngIRCd.pmdoc/index.xml +++ b/contrib/MacOSX/ngIRCd.pmdoc/index.xml @@ -4,7 +4,7 @@ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural \f0\i\fs24 \cf0 ngIRCd -- The Next Generation IRC Daemon\ -Copyright (c)2001-2009 Alexander Barton and Contributors.\ +Copyright (c)2001-2010 Alexander Barton and Contributors.\ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural \i0 \cf0 \ @@ -187,4 +187,4 @@ To disable automatic starting of ngIRCd, use this command:\ \ls2\ilvl0 \f1\fs24 \cf0 sudo launchctl unload -w \\\ /Library/LaunchDaemons/de.barton.ngircd.plist\ -}]]>01ngircd.xml02de.xmlproperties.customizeOptionproperties.titledescriptionproperties.anywhereDomainproperties.systemDomain \ No newline at end of file +}]]>01ngircd.xml02de.xmlproperties.customizeOptionproperties.titledescriptionproperties.anywhereDomainproperties.systemDomain diff --git a/contrib/ngircd.spec b/contrib/ngircd.spec index d83ff70..b957517 100644 --- a/contrib/ngircd.spec +++ b/contrib/ngircd.spec @@ -1,5 +1,5 @@ %define name ngircd -%define version 16~rc1 +%define version 16~rc2 %define release 1 %define prefix %{_prefix} diff --git a/doc/Platforms.txt b/doc/Platforms.txt index 8629252..7a6e3a8 100644 --- a/doc/Platforms.txt +++ b/doc/Platforms.txt @@ -1,7 +1,7 @@ ngIRCd - Next Generation IRC Server - (c)2001-2009 Alexander Barton + (c)2001-2010 Alexander Barton alex@barton.de, http://www.barton.de/ ngIRCd is free software and published under the @@ -32,23 +32,24 @@ hppa1.1/unknown/linux-gnu gcc 3.3.3 0.8.0 04-05-30 alex Y Y Y Y hppa2.0/unknown/linux-gnu gcc 3.3.5 13~rc1 08-12-02 alex Y Y Y Y hppa2.0w-hp-hpux11.11 gcc 4.2.3 14.1 09-07-22 goetz Y Y Y Y i386/apple/darwin9.7.0 gcc 4.0.1 14.1 09-08-04 alex Y Y Y Y (3) -i386/apple/darwin10.0.0b2 gcc 4.2.1 14.1 09-07-27 alex Y Y Y Y (3) +i386/apple/darwin10.3.0 gcc 4.2.1 16 10-04-23 alex Y Y Y Y (3) i386/pc/solaris2.9 gcc 3.2.2 CVSHEAD 04-02-24 alex Y Y Y Y i386/pc/solaris2.11 gcc 3.4.3 14.1 09-08-03 alex Y Y Y Y (4) i386/unknown/freebsd5.2.1 gcc 3.3.3 0.8.0 04-05-30 alex Y Y Y Y i386/unknown/freebsd6.0 gcc 3.4.4 0.10.0-p1 06-08-04 alex Y Y Y Y (3) i386/unknown/freebsd6.1 gcc 3.4.4 CVSHEAD 06-05-07 fw Y Y Y Y (3) -i386/unknown/freebsd6.2 gcc 3.4.6 14.1 09-07-27 alex Y Y Y Y (3) +i386/unknown/freebsd6.2 gcc 3.4.6 16 10-04-11 alex Y Y Y Y (3) i386/unknown/freebsd7.0 gcc 4.2.1 14.1 09-07-28 alex Y Y Y Y (3) i386/unknown/freebsd7.2 gcc 4.2.1 14.1 09-08-03 alex Y Y Y Y (3) +i386/unknown/freebsd7.3 gcc 4.2.1 16 10-04-11 alex Y Y Y Y (3) i386/unknown/gnu0.3 gcc 3.3.3 0.8.0 04-05-30 alex Y Y n Y i686/unknown/gnu0.3 gcc 4.3.1 14.1 09-07-28 alex Y Y Y Y i686/unkn./kfreebsd7.2-gnu gcc 4.3.4 15 09-12-02 alex Y Y Y Y (3) i386/unknown/netbsdelf1.6.1 gcc 2.95.3 CVSHEAD 04-02-24 alex Y Y Y Y i386/unknown/netbsdelf3.0.1 gcc 3.3.3 0.10.0-p1 06-08-30 alex Y Y Y Y (3) -i386/unknown/netbsdelf4.0 gcc 4.1.2 14.1 09-07-28 alex Y Y Y Y (3) +i386/unknown/netbsdelf4.0 gcc 4.1.2 16 10-04-11 alex Y Y Y Y (3) i386/unknown/openbsd3.9 gcc 3.3.5 0.10.0-p1 06-08-30 alex Y Y Y Y (3) -i386/unknown/openbsd4.1 gcc 3.3.5 14.1 09-07-28 alex Y Y Y Y (3) +i386/unknown/openbsd4.1 gcc 3.3.5 16 10-04-11 alex Y Y Y Y (3) i586/pc/interix3.5 gcc 3.3 15 10-01-22 alex Y Y N Y i686/pc/cygwin gcc 3.3.1 0.8.0 04-05-30 alex Y Y n Y i686/pc/linux-gnu gcc 2.95.4 0.8.0 04-05-30 alex Y Y Y Y (1) @@ -67,7 +68,8 @@ powerpc/unknown/openbsd3.6 gcc 2.95.3 0.10.0 06-10-08 alex Y Y n Y sparc/sun/solaris2.6 gcc 2.95.3 0.7.x-CVS 03-04-22 alex Y Y Y Y sparc/sun/solaris2.7 gcc 3.3 0.8.0 04-05-30 alex Y Y Y Y sparc/unkn./netbsdelf1.6.1 gcc 2.95.3 0.8.0 04-05-30 alex Y Y Y Y -x86_64/unknown/linux-gnu gcc 4.3.2 14.1 09-08-04 alex Y Y Y Y (1) +x86_64/unknown/freebsd8.0 gcc 4.2.1 16 10-04-23 alex Y Y Y Y (3) +x86_64/unknown/linux-gnu gcc 4.3.2 16 10-04-23 alex Y Y Y Y (1) Notes diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index cd350a8..4367754 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2009 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2010 Alexander Barton * * 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 @@ -37,6 +37,9 @@ #include #ifdef HAVE_NETINET_IP_H +# ifdef HAVE_NETINET_IN_SYSTM_H +# include +# endif # include #endif @@ -92,10 +95,12 @@ static bool Init_Socket PARAMS(( int Sock )); static void New_Server PARAMS(( int Server, ng_ipaddr_t *dest )); static void Simple_Message PARAMS(( int Sock, const char *Msg )); static int NewListener PARAMS(( const char *listen_addr, UINT16 Port )); +static void Account_Connection PARAMS((void)); + static array My_Listeners; static array My_ConnArray; -static size_t NumConnections; +static size_t NumConnections, NumConnectionsMax, NumConnectionsAccepted; #ifdef TCPWRAP int allow_severity = LOG_INFO; @@ -366,8 +371,8 @@ Conn_Init( void ) Pool_Size = Conf_MaxConnections; if (!array_alloc(&My_ConnArray, sizeof(CONNECTION), (size_t)Pool_Size)) { - Log( LOG_EMERG, "Can't allocate memory! [Conn_Init]" ); - exit( 1 ); + Log(LOG_EMERG, "Can't allocate memory! [Conn_Init]"); + exit(1); } /* FIXME: My_Connetions/Pool_Size is needed by other parts of the @@ -375,17 +380,15 @@ Conn_Init( void ) My_Connections = (CONNECTION*) array_start(&My_ConnArray); LogDebug("Allocated connection pool for %d items (%ld bytes).", - array_length(&My_ConnArray, sizeof( CONNECTION )), array_bytes(&My_ConnArray)); + array_length(&My_ConnArray, sizeof(CONNECTION)), + array_bytes(&My_ConnArray)); - assert( array_length(&My_ConnArray, sizeof( CONNECTION )) >= (size_t) Pool_Size); + assert(array_length(&My_ConnArray, sizeof(CONNECTION)) >= (size_t)Pool_Size); array_free( &My_Listeners ); - /* Connection-Struktur initialisieren */ - for( i = 0; i < Pool_Size; i++ ) Init_Conn_Struct( i ); - - /* Global write counter */ - WCounter = 0; + for (i = 0; i < Pool_Size; i++) + Init_Conn_Struct(i); } /* Conn_Init */ @@ -1098,6 +1101,27 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie } /* Conn_Close */ +GLOBAL long +Conn_Count(void) +{ + return NumConnections; +} /* Conn_Count */ + + +GLOBAL long +Conn_CountMax(void) +{ + return NumConnectionsMax; +} /* Conn_CountMax */ + + +GLOBAL long +Conn_CountAccepted(void) +{ + return NumConnectionsAccepted; +} /* Conn_CountAccepted */ + + GLOBAL void Conn_SyncServerStruct( void ) { @@ -1238,6 +1262,7 @@ New_Connection(int Sock) Log(LOG_CRIT, "Can't accept connection: %s!", strerror(errno)); return -1; } + NumConnectionsAccepted++; if (!ng_ipaddr_tostr_r(&new_addr, ip_str)) { Log(LOG_CRIT, "fd %d: Can't convert IP address!", new_sock); @@ -1357,12 +1382,22 @@ New_Connection(int Sock) * If there are results earlier, the delay is aborted. */ Conn_SetPenalty(new_sock, 4); - NumConnections++; - LogDebug("Total number of connections now %ld.", NumConnections); + Account_Connection(); return new_sock; } /* New_Connection */ +static void +Account_Connection(void) +{ + NumConnections++; + if (NumConnections > NumConnectionsMax) + NumConnectionsMax = NumConnections; + LogDebug("Total number of connections now %lu (max %lu).", + NumConnections, NumConnectionsMax); +} /* Account_Connection */ + + static CONN_ID Socket2Index( int Sock ) { @@ -1802,7 +1837,7 @@ New_Server( int Server , ng_ipaddr_t *dest) } /* Conn_Close() decrements this counter again */ - NumConnections++; + Account_Connection(); Client_SetIntroducer( c, c ); Client_SetToken( c, TOKEN_OUTBOUND ); @@ -2025,20 +2060,32 @@ cb_Read_Resolver_Result( int r_fd, UNUSED short events ) } /* cb_Read_Resolver_Result */ +/** + * Write a "simple" (error) message to a socket. + * The message is sent without using the connection write buffers, without + * compression/encryption, and even without any error reporting. It is + * designed for error messages of e.g. New_Connection(). */ static void -Simple_Message( int Sock, const char *Msg ) +Simple_Message(int Sock, const char *Msg) { char buf[COMMAND_LEN]; size_t len; - /* Write "simple" message to socket, without using compression - * or even the connection write buffers. Used e.g. for error - * messages by New_Connection(). */ - assert( Sock > NONE ); - assert( Msg != NULL ); - - strlcpy( buf, Msg, sizeof buf - 2); - len = strlcat( buf, "\r\n", sizeof buf); - (void)write(Sock, buf, len); + + assert(Sock > NONE); + assert(Msg != NULL); + + strlcpy(buf, Msg, sizeof buf - 2); + len = strlcat(buf, "\r\n", sizeof buf); + if (write(Sock, buf, len) < 0) { + /* Because this function most probably got called to log + * an error message, any write error is ignored here to + * avoid an endless loop. But casting the result of write() + * to "void" doesn't satisfy the GNU C code attribute + * "warn_unused_result" which is used by some versions of + * glibc (e.g. 2.11.1), therefore this silly error + * "handling" code here :-( */ + return; + } } /* Simple_Error */ diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h index b94b10d..f2ec823 100644 --- a/src/ngircd/conn.h +++ b/src/ngircd/conn.h @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2009 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2010 Alexander Barton * * 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 @@ -122,5 +122,9 @@ static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; } #endif #endif +GLOBAL long Conn_Count PARAMS((void)); +GLOBAL long Conn_CountMax PARAMS((void)); +GLOBAL long Conn_CountAccepted PARAMS((void)); + /* -eof- */ diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 28722e7..7d7bb88 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2009 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2010 Alexander Barton * * 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 @@ -1176,6 +1176,10 @@ IRC_Send_LUSERS( CLIENT *Client ) if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client), cnt, max, cnt, max)) return DISCONNECTED; + /* Connection counters */ + if (! IRC_WriteStrClient(Client, RPL_STATSCONN_MSG, Client_ID(Client), + Conn_CountMax(), Conn_CountAccepted())) + return DISCONNECTED; #endif return CONNECTED; diff --git a/src/ngircd/log.c b/src/ngircd/log.c index 5a81b5b..ff81163 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -146,8 +146,8 @@ GLOBAL void Log_Exit( void ) { /* Good Bye! */ - if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE_NAME ); - else Log( LOG_NOTICE, "%s done.", PACKAGE_NAME ); + Log(LOG_NOTICE, "%s done%s, served %lu connections.", PACKAGE_NAME, + NGIRCd_SignalRestart ? " (restarting)" : "", Conn_CountAccepted()); #ifdef DEBUG if( Error_File[0] ) diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index e15bf16..c356e42 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -46,6 +46,7 @@ #define RPL_TRACEEND_MSG "262 %s %s %s-%s.%s :End of TRACE" #define RPL_LOCALUSERS_MSG "265 %s %lu %lu :Current local users: %lu, Max: %lu" #define RPL_NETUSERS_MSG "266 %s %lu %lu :Current global users: %lu, Max: %lu" +#define RPL_STATSCONN_MSG "250 %s :Highest connection count: %lu (%lu connections received)" #define RPL_AWAY_MSG "301 %s %s :%s" #define RPL_USERHOST_MSG "302 %s :" diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index 5fc88c9..b951bad 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2009 Alexander Barton (alex@barton.de). + * Copyright (c)2001-2010 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 @@ -562,7 +562,7 @@ static void Show_Version( void ) { puts( NGIRCd_Version ); - puts( "Copyright (c)2001-2009 Alexander Barton () and Contributors." ); + puts( "Copyright (c)2001-2010 Alexander Barton () and Contributors." ); puts( "Homepage: \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." ); @@ -798,7 +798,9 @@ NGIRCd_Init( bool NGIRCd_NoDaemon ) #else setpgrp(0, getpid()); #endif - chdir( "/" ); + if (chdir( "/" ) != 0) + Log(LOG_ERR, "Can't change directory to '/': %s", + strerror(errno)); /* Detach stdin, stdout and stderr */ Setup_FDStreams( ); diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 37d1c51..bccf518 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -144,8 +144,8 @@ Resolve_Init(RES_STAT *s) } -#ifndef WANT_IPV6 -#ifdef h_errno +#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) +#if !defined(WANT_IPV6) && defined(h_errno) static char * Get_Error( int H_Error ) { @@ -162,8 +162,8 @@ Get_Error( int H_Error ) } return "unknown error"; } -#endif /* h_errno */ -#endif /* WANT_IPV6 */ +#endif +#endif /* Do "IDENT" (aka "AUTH") lookup and append result to resolved_addr array */