Commit Diff


commit - 0b114e814b9b12bd06052329d8b7815e7ea70a08
commit + d155ed17c8ed3153250ca79ce7f634db1f6713c4
blob - 17d5ef868a06bfbd8f0daa08c28d700859235b50
blob + a37c10919e6aa4ddfc8704bdf8a5c8da658d14c1
--- AUTHORS
+++ AUTHORS
@@ -12,15 +12,22 @@
 
 Main Authors
 ~~~~~~~~~~~~
-Alexander Barton, <alex@barton.de>, "alex"
+Alexander Barton, <alex@barton.de> (alex)
 
 
 Contributors
 ~~~~~~~~~~~~
-Goetz Hoffart, <goetz@hoffart.de>
-Ilja Osthoff, <i.osthoff@gmx.net>
+Goetz Hoffart, <goetz@hoffart.de> (goetz)
+Ilja Osthoff, <i.osthoff@gmx.net> (ilja)
 Sean Reifschneider, <jafo-rpms@tummy.com>
 
 
+Code snippets
+~~~~~~~~~~~~~
+J. Kercheval: pattern matching functions
+Patrick Powell, <papowell@astart.com>: snprintf()-function
+Andrew Tridgell & Martin Pool: strl{cpy|cat}()-functions
+
+
 -- 
-$Id: AUTHORS,v 1.5 2003/04/21 21:33:18 alex Exp $
+$Id: AUTHORS,v 1.5.2.1 2003/11/07 20:51:08 alex Exp $
blob - db88626baf25fda101f9bd00f66b171d1faff199
blob + 114bbccc27a457129c78990315f12db5fceddc0a
--- ChangeLog
+++ ChangeLog
@@ -10,8 +10,27 @@
                                -- ChangeLog --
 
 
+ngIRCd 0.7.5 (2003-11-07)
+
+  - Fixed ban behavior: users which are banned from a channel can't no
+    longer send PRIVMSG's to this channel (fixes Bug #47).
+  - Fixed and enhanced the "penalty handling" of the server: commands that
+    require more resources block the client for a short time.
+  - Changed the internal time resolution to one second.
+  - New configuration variable "MaxConnectionsIP" to limit the number of
+    simultaneous connections from a single IP that the server will accept.
+    This configuration options lowers the risk of denial of service attacks
+    (DoS), the default is 5 connections per client IP.
+  - Fixed build problems under Mac OS X 10.3.
+  - Use "-pipe" when compiling with gcc, speeds things up a little :-)
+  - Added new configuration variable "Listen" to bind all listening
+    sockets of the server to a single IP address.
+  - Suppress misleading error message of diff during make run.
+  - Enhanced test-suite and made it work on GNU/Hurd.
+  - Fixed minor typo in debug output :-)
+
 ngIRCd 0.7.1 (2003-07-18)
-  
+
   - Included files to build Debian packages (located in "debian/").
   - Updated config.guess and config.sub to newer upstream versions.
   - NJOIN propagates user channel modes correctly again ... Upsa.
@@ -458,4 +477,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.188.2.17 2003/07/18 20:54:47 alex Exp $
+$Id: ChangeLog,v 1.188.2.18 2003/11/07 20:51:08 alex Exp $
blob - 15f5f55286242481b63c2005c780483b484666e4
blob + 5bb988e17e77205c9a3255f0a7ac737bc9d59801
--- MacOSX/ngircd.pbproj/project.pbxproj
+++ MacOSX/ngircd.pbproj/project.pbxproj
@@ -218,7 +218,8 @@
 			);
 			isa = PBXGroup;
 			name = Products;
-			refType = 4;
+			path = "";
+			refType = 2;
 		};
 //1A0
 //1A1
@@ -421,10 +422,10 @@
 		};
 		F51F791401DFD0DE01D13771 = {
 			children = (
-				FA550F3103D59CB300A85B04,
 				F5263AEF01E2A9B801CE8F8F,
 				F51F791501DFD0DE01D13771,
 				F5E9447D02C9EE2801A85B04,
+				FA0B193305060CB800A85B04,
 				F5B565290325412B01A85B04,
 				F5E9447E02C9EE2801A85B04,
 				F5E9447F02C9EE2801A85B04,
@@ -433,8 +434,8 @@
 			);
 			isa = PBXGroup;
 			name = doc;
-			path = /Users/alex/Develop/ngircd/doc;
-			refType = 0;
+			path = ../doc;
+			refType = 2;
 		};
 		F51F791501DFD0DE01D13771 = {
 			fileEncoding = 5;
@@ -477,8 +478,8 @@
 			);
 			isa = PBXGroup;
 			name = testsuite;
-			path = /Users/alex/Develop/ngircd/src/testsuite;
-			refType = 0;
+			path = ../src/testsuite;
+			refType = 2;
 		};
 		F520AEA90335E29001A85B04 = {
 			fileEncoding = 5;
@@ -593,8 +594,8 @@
 			);
 			isa = PBXGroup;
 			name = man;
-			path = /Users/alex/Develop/ngircd/man;
-			refType = 0;
+			path = ../man;
+			refType = 2;
 		};
 		F520AF180335F1B801A85B04 = {
 			fileEncoding = 5;
@@ -691,8 +692,9 @@
 				F576ABFE01D61D7401A85B03,
 			);
 			isa = PBXGroup;
-			path = ngircd;
-			refType = 4;
+			name = ngircd;
+			path = ../src/ngircd;
+			refType = 2;
 		};
 		F52162BB01C7B904012300F4 = {
 			fileEncoding = 5;
@@ -1034,7 +1036,7 @@
 			);
 			isa = PBXGroup;
 			path = ngircd.pbproj;
-			refType = 4;
+			refType = 2;
 		};
 		F56D8BA101E0BFA00155ADA7 = {
 			fileEncoding = 5;
@@ -1275,7 +1277,8 @@
 			);
 			isa = PBXGroup;
 			name = contrib;
-			refType = 4;
+			path = "";
+			refType = 2;
 		};
 		F5D3536203892AD201A85B04 = {
 			fileEncoding = 5;
@@ -1377,8 +1380,8 @@
 			);
 			isa = PBXGroup;
 			name = portab;
-			path = /Users/alex/Develop/ngircd/src;
-			refType = 0;
+			path = ../src/portab;
+			refType = 2;
 		};
 		F5F18133023EC63701A85B04 = {
 			fileEncoding = 5;
@@ -1443,6 +1446,13 @@
 //FA2
 //FA3
 //FA4
+		FA0B193305060CB800A85B04 = {
+			fileEncoding = 5;
+			isa = PBXFileReference;
+			name = Platforms.txt;
+			path = ../doc/Platforms.txt;
+			refType = 2;
+		};
 		FA42C8AD03C0A00B00A85B04 = {
 			fileEncoding = 4;
 			isa = PBXFileReference;
@@ -1503,7 +1513,8 @@
 			);
 			isa = PBXGroup;
 			name = tool;
-			refType = 4;
+			path = ../src;
+			refType = 2;
 		};
 		FA550F2A03D59C8200A85B04 = {
 			fileEncoding = 5;
@@ -1549,94 +1560,7 @@
 			isa = PBXBuildFile;
 			settings = {
 			};
-		};
-		FA550F3103D59CB300A85B04 = {
-			children = (
-				FA550F3503D59CD800A85B04,
-				FA550F3403D59CD800A85B04,
-				FA550F3703D59CD800A85B04,
-				FA550F3203D59CD800A85B04,
-				FA550F3303D59CD800A85B04,
-				FA550F3603D59CD800A85B04,
-				FA550F3803D59CD800A85B04,
-				FA550F3903D59CD800A85B04,
-				FA550F3A03D59CD800A85B04,
-				FA550F3B03D59CD800A85B04,
-			);
-			isa = PBXGroup;
-			name = de;
-			refType = 4;
-		};
-		FA550F3203D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = CVS.txt;
-			path = ../doc/de/CVS.txt;
-			refType = 2;
 		};
-		FA550F3303D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = FAQ.txt;
-			path = ../doc/de/FAQ.txt;
-			refType = 2;
-		};
-		FA550F3403D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = INSTALL;
-			path = ../doc/de/INSTALL;
-			refType = 2;
-		};
-		FA550F3503D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = Makefile.am;
-			path = ../doc/de/Makefile.am;
-			refType = 2;
-		};
-		FA550F3603D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = Protocol.txt;
-			path = ../doc/de/Protocol.txt;
-			refType = 2;
-		};
-		FA550F3703D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = README;
-			path = ../doc/de/README;
-			refType = 2;
-		};
-		FA550F3803D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = "README-AUX.txt";
-			path = "../doc/de/README-AUX.txt";
-			refType = 2;
-		};
-		FA550F3903D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = "README-BeOS.txt";
-			path = "../doc/de/README-BeOS.txt";
-			refType = 2;
-		};
-		FA550F3A03D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = RFC.txt;
-			path = ../doc/de/RFC.txt;
-			refType = 2;
-		};
-		FA550F3B03D59CD800A85B04 = {
-			fileEncoding = 5;
-			isa = PBXFileReference;
-			name = "sample-ngircd.conf";
-			path = "../doc/de/sample-ngircd.conf";
-			refType = 2;
-		};
 		FAC0383C03BB318400A85B04 = {
 			fileRef = F51044520297ABF80173DE11;
 			isa = PBXBuildFile;
blob - c28214cac1e9a66fd1688b6690c065b6829bfe26
blob + 9fa176c55666e350f93b85542eea9cec7bed98e8
--- NEWS
+++ NEWS
@@ -10,6 +10,15 @@
                                   -- NEWS --
 
 
+ngIRCd 0.7.5 (2003-07-11)
+
+  - New configuration variable "MaxConnectionsIP" to limit the number of
+    simultaneous connections from a single IP that the server will accept.
+    This configuration options lowers the risk of denial of service attacks
+    (DoS), the default is 5 connections per client IP.
+  - Added new configuration variable "Listen" to bind all listening
+    sockets of the server to a single IP address.
+
 ngIRCd 0.7.1 (2003-07-18)
 
   - Added support for GNU/Hurd.
@@ -165,4 +174,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: NEWS,v 1.53.2.4 2003/07/18 20:54:47 alex Exp $
+$Id: NEWS,v 1.53.2.5 2003/11/07 20:51:08 alex Exp $
blob - 00b25cd8d7349a0b696c37fe2b2e471ab8b0b397
blob + c70c2c7d18971ba0c978deda107a31a47bd8b4df
--- configure.in
+++ configure.in
@@ -8,13 +8,13 @@
 # (at your option) any later version.
 # Please read the file COPYING, README and AUTHORS for more information.
 #
-# $Id: configure.in,v 1.89.2.10 2003/07/18 20:55:10 alex Exp $
+# $Id: configure.in,v 1.89.2.11 2003/11/07 20:51:08 alex Exp $
 #
 
 # -- Initialisierung --
 
 AC_PREREQ(2.50)
-AC_INIT(ngircd, 0.7.1)
+AC_INIT(ngircd, 0.7.5)
 AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE(1.6)
@@ -271,7 +271,7 @@ if test "$GCC" = "yes"; then
 	ansi=" -ansi"
 	pedantic=" -pedantic"
 
-	$CC --version | grep 20020420 > /dev/null 2>&1
+	$CC --version | grep 20020420 >/dev/null 2>&1
 	if test $? -eq 0; then
 		# Mac OS X (and Darwin?) ship with a slightly broken
 		# prerelease of GCC 3.1 which don't like -pedantic:
@@ -279,15 +279,24 @@ if test "$GCC" = "yes"; then
 		pedantic=""
 	fi
 
-	uname | grep "CYGWIN" > /dev/null 2>&1
+	$CC --version | grep 20030304 >/dev/null 2>&1
 	if test $? -eq 0; then
+		# Mac OS X 10.3 (and Darwin 7.0?) have a strange gcc (or
+		# system header files?) which produces lots of errors when
+		# using -ansi; so we don't =:-)
+		AC_MSG_RESULT([detected broken GNU C compiler, disabling "-ansi"])
+		ansi=""
+	fi
+
+	uname | grep "CYGWIN" >/dev/null 2>&1
+	if test $? -eq 0; then
 		# The include files of Cygwin don't like -ansi,
 		# so we disable it:
 		AC_MSG_RESULT([detected Cygwin, disabling "-ansi"])
 		ansi=""
 	fi
 
-	add_CFLAGS="-Wall -W${ansi}${pedantic} $CFLAGS $CFLAGS_ADD"
+	add_CFLAGS="-pipe -Wall -W${ansi}${pedantic} $CFLAGS $CFLAGS_ADD"
 else
 	the_CFLAGS="$CFLAGS"
 	add_CFLAGS="$CFLAGS_ADD"
blob - abe7192e86aba04ad50be9b78337273bb28dfa3c
blob + 1f6e2014e44bb424173ea9d1303077f07dee6f60
--- contrib/ngircd.spec
+++ contrib/ngircd.spec
@@ -1,5 +1,5 @@
 %define name    ngircd
-%define version 0.7.1
+%define version 0.7.5
 %define release 1
 %define prefix  %{_prefix}
 
blob - 8d2b257ee3703136f8cbe3d87a2c5bac925b99dc
blob + c6d263fb67218b01cf40fd166d1d84ae9edc0a2f
--- doc/sample-ngircd.conf
+++ doc/sample-ngircd.conf
@@ -1,4 +1,4 @@
-# $Id: sample-ngircd.conf,v 1.20.2.2 2003/04/29 12:37:17 alex Exp $
+# $Id: sample-ngircd.conf,v 1.20.2.3 2003/11/07 20:51:09 alex Exp $
 
 #
 # This is a sample configuration file for the ngIRCd, which must adept to
@@ -36,6 +36,10 @@
 	# Ports on which the server should listen. There may be more than
 	# one port, separated with ";". (Default: 6667)
 	;Ports = 6667, 6668, 66694
+
+	# IP address on which the server should listen. (Default: empty,
+	# so the server listens on all IP addresses of the system)
+	;Listen = 1.2.3.4
 	
 	# Text file with the "message of the day" (MOTD). This message will
 	# be shown to all users connecting to the server:
@@ -72,6 +76,10 @@
 	# Maximum number of simultaneous connection the server is allowed
 	# to accept (<=0: unlimited):
 	;MaxConnections = -1
+	
+	# Maximum number of simultaneous connections from a single IP address
+	# the server will accept (<=0: unlimited):
+	;MaxConnectionsIP = 5
 
 	# Maximum number of channels a user can be member of (<=0: no limit):
 	;MaxJoins = 10
blob - ceaff38d16d8926294e25ec6c31d58de6850dc7d
blob + 548e49355655bff47fb2234d6cee52bb90d0ada6
--- man/ngircd.conf.5
+++ man/ngircd.conf.5
@@ -1,5 +1,5 @@
 .\"
-.\" $Id: ngircd.conf.5,v 1.9.2.1 2003/07/18 20:48:20 alex Exp $
+.\" $Id: ngircd.conf.5,v 1.9.2.2 2003/11/07 20:51:10 alex Exp $
 .\"
 .TH ngircd.conf 5 "Mai 2003" ngircd "ngIRCd Manual"
 .SH NAME
@@ -67,6 +67,10 @@ command.
 Ports on which the server should listen. There may be more than one port,
 separated with ';'. Default: 6667.
 .TP
+\fBListen\fR
+The ip address on which the server should listen. Default is empty, so
+the server listens on all configured ip addresses and interfaces.
+.TP
 \fBMotdFile\fR
 Text file with the "message of the day" (MOTD). This message will be shown
 to all users connecting to the server.
@@ -114,6 +118,11 @@ not(!) channel-operators? Default: no.
 Maximum number of simultaneous connection the server is allowed to accept
 (<=0: unlimited). Default: -1.
 .TP
+\fBMaxConnectionsIP\fR
+Maximum number of simultaneous connections from a single IP address that
+the server will accept (<=0: unlimited). This configuration options lowers
+the risk of denial of service attacks (DoS). Default: 5.
+.TP
 \fBMaxJoins\fR
 Maximum number of channels a user can be member of (<=0: no limit).
 Default: 10.
blob - a0aa3e0f1a7f81c955d00e97f148f5caa72d89f9
blob + 84ab5785d48ae9565ff99811f63cd93cd8adfbb6
--- src/ngircd/Makefile.am
+++ src/ngircd/Makefile.am
@@ -8,7 +8,7 @@
 # (at your option) any later version.
 # Please read the file COPYING, README and AUTHORS for more information.
 #
-# $Id: Makefile.am,v 1.39.2.1 2003/07/18 20:49:05 alex Exp $
+# $Id: Makefile.am,v 1.39.2.2 2003/11/07 20:51:10 alex Exp $
 #
 
 AUTOMAKE_OPTIONS = ../portab/ansi2knr
@@ -71,7 +71,8 @@ cvs-date:
 	    | $(AWK) "{ print \$$9 }" | sort | tail -1 \
 	    | sed -e "s/\//-/g" )\"" > cvs-version.new \
 	 || echo "" > cvs-version.new
-	diff cvs-version.h cvs-version.new || cp cvs-version.new cvs-version.h
+	diff cvs-version.h cvs-version.new 2>/dev/null \
+	 || cp cvs-version.new cvs-version.h
 
 TESTS = check-version check-help
 
blob - 0b2b1ff18afe97c528f981c14bd0deefa68ae3f5
blob + eaa3007c60afb7dc83a1d85dcfd1c4d79c4ecc0f
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -17,7 +17,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.42 2002/12/30 17:15:42 alex Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.42.2.1 2003/11/07 20:51:10 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -669,7 +669,7 @@ Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Cl
 {
 	BOOLEAN is_member, has_voice, is_op, ok;
 
-	/* Okay, Ziel ist ein Channel */
+	/* Okay, target is a channel */
 	is_member = has_voice = is_op = FALSE;
 	if( Channel_IsMemberOf( Chan, From ))
 	{
@@ -678,14 +678,21 @@ Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Cl
 		if( strchr( Channel_UserModes( Chan, From ), 'o' )) is_op = TRUE;
 	}
 
-	/* pruefen, ob Client in Channel schreiben darf */
+	/* Check weather client is allowed to write to channel */
 	ok = TRUE;
 	if( strchr( Channel_Modes( Chan ), 'n' ) && ( ! is_member )) ok = FALSE;
 	if( strchr( Channel_Modes( Chan ), 'm' ) && ( ! is_op ) && ( ! has_voice )) ok = FALSE;
+	
+	/* Is the client banned? */
+	if( Lists_CheckBanned( From, Chan ))
+	{
+		/* Client is banned, bus is he channel operator or has voice? */
+		if(( ! has_voice ) && ( ! is_op )) ok = FALSE;
+	}
 
 	if( ! ok ) return IRC_WriteStrClient( From, ERR_CANNOTSENDTOCHAN_MSG, Client_ID( From ), Channel_Name( Chan ));
 
-	/* Text senden */
+	/* Send text */
 	if( Client_Conn( From ) > NONE ) Conn_UpdateIdle( Client_Conn( From ));
 	return IRC_WriteStrChannelPrefix( Client, Chan, From, TRUE, "PRIVMSG %s :%s", Channel_Name( Chan ), Text );
 } /* Channel_Write */
blob - 0eb0d88eb5c2dec4a2b168f9550c245126a3167b
blob + 2d8a8c59d77d2e73c03582a5ed8f0193f1b64fad
--- src/ngircd/conf.c
+++ src/ngircd/conf.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.57.2.2 2003/04/29 12:37:18 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.57.2.3 2003/11/07 20:51:10 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -120,6 +120,7 @@ Conf_Test( VOID )
 		printf( "%u", Conf_ListenPorts[i] );
 	}
 	puts( "" );
+	printf( "  Listen = %s\n", Conf_ListenAddress );
 	pwd = getpwuid( Conf_UID );
 	if( pwd ) printf( "  ServerUID = %s\n", pwd->pw_name );
 	else printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
@@ -132,6 +133,8 @@ Conf_Test( VOID )
 	printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
 	if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
 	else printf( "  MaxConnections = -1\n" );
+	if( Conf_MaxConnectionsIP > 0 ) printf( "  MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP );
+	else printf( "  MaxConnectionsIP = -1\n" );
 	if( Conf_MaxJoins > 0 ) printf( "  MaxJoins = %d\n", Conf_MaxJoins );
 	else printf( "  MaxJoins = -1\n" );
 	puts( "" );
@@ -340,6 +343,7 @@ Set_Defaults( BOOLEAN InitServers )
 	strlcat( Conf_MotdFile, MOTD_FILE, sizeof( Conf_MotdFile ));
 
 	Conf_ListenPorts_Count = 0;
+	strcpy( Conf_ListenAddress, "" );
 
 	Conf_UID = Conf_GID = 0;
 	
@@ -354,6 +358,7 @@ Set_Defaults( BOOLEAN InitServers )
 	Conf_OperCanMode = FALSE;
 	
 	Conf_MaxConnections = -1;
+	Conf_MaxConnectionsIP = 5;
 	Conf_MaxJoins = 10;
 
 	/* Initialize server configuration structures */
@@ -687,6 +692,16 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
 		else
 #endif
 		Conf_MaxConnections = atol( Arg );
+		return;
+	}
+	if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 )
+	{
+		/* Maximum number of simoultanous connections from one IP. Values <= 0 are equal to "no limit". */
+#ifdef HAVE_ISDIGIT
+		if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnectionsIP\" is not a number!", NGIRCd_ConfFile, Line );
+		else
+#endif
+		Conf_MaxConnectionsIP = atoi( Arg );
 		return;
 	}
 	if( strcasecmp( Var, "MaxJoins" ) == 0 )
@@ -697,6 +712,15 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
 		else
 #endif
 		Conf_MaxJoins = atoi( Arg );
+		return;
+	}
+	if( strcasecmp( Var, "Listen" ) == 0 )
+	{
+		/* IP-Address to bind sockets */
+		if( strlcpy( Conf_ListenAddress, Arg, sizeof( Conf_ListenAddress )) >= sizeof( Conf_ListenAddress ))
+		{
+			Config_Error( LOG_WARNING, "%s, line %d: Value of \"Listen\" too long!", NGIRCd_ConfFile, Line );
+		}
 		return;
 	}
 
blob - 47784ba40d94c942a8634cc26cdb8c16c9679617
blob + 058d423212b43f9ea2edc72de8e156c408898e5f
--- src/ngircd/conf.h
+++ src/ngircd/conf.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.26 2002/12/31 16:12:50 alex Exp $
+ * $Id: conf.h,v 1.26.2.1 2003/11/07 20:51:11 alex Exp $
  *
  * Configuration management (header)
  */
@@ -76,6 +76,9 @@ GLOBAL CHAR Conf_MotdFile[FNAME_LEN];
 GLOBAL UINT Conf_ListenPorts[MAX_LISTEN_PORTS];
 GLOBAL INT Conf_ListenPorts_Count;
 
+/* Address to which the socket should be bound or empty (=all) */
+GLOBAL CHAR Conf_ListenAddress[16];
+
 /* User and group ID the server should run with */
 GLOBAL UINT Conf_UID;
 GLOBAL UINT Conf_GID;
@@ -107,7 +110,10 @@ GLOBAL LONG Conf_MaxConnections;
 /* Maximum number of channels a user can join */
 GLOBAL INT Conf_MaxJoins;
 
+/* Maximum number of connections per IP address */
+GLOBAL INT Conf_MaxConnectionsIP;
 
+
 GLOBAL VOID Conf_Init PARAMS((VOID ));
 GLOBAL VOID Conf_Rehash PARAMS((VOID ));
 GLOBAL INT Conf_Test PARAMS((VOID ));
blob - 172784b660f4a650cd731b49e8ad9bcfa0e52fb3
blob + 0723c43e9ddd0e4e3870a1275bccd8d3abe4f86a
--- src/ngircd/conn-func.c
+++ src/ngircd/conn-func.c
@@ -16,10 +16,11 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conn-func.c,v 1.1 2002/12/30 17:14:28 alex Exp $";
+static char UNUSED id[] = "$Id: conn-func.c,v 1.1.2.1 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
+#include <log.h>
 
 #include "conn.h"
 
@@ -69,7 +70,7 @@ Conn_SetPenalty( CONN_ID Idx, time_t Seconds )
 	
 	assert( Idx > NONE );
 	assert( Seconds >= 0 );
-	
+
 	t = time( NULL ) + Seconds;
 	if( t > My_Connections[Idx].delaytime ) My_Connections[Idx].delaytime = t;
 } /* Conn_SetPenalty */
blob - 4742c865bd2e44501be780618ba7731be19ceef7
blob + 29dde448770a65e86e293c1977cb27b5c50dd315
--- src/ngircd/conn.c
+++ src/ngircd/conn.c
@@ -16,7 +16,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conn.c,v 1.122.2.1 2003/04/25 16:50:53 alex Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.122.2.2 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -87,6 +87,7 @@ LOCAL BOOLEAN Init_Socket PARAMS(( INT Sock ));
 LOCAL VOID New_Server PARAMS(( INT Server, CONN_ID Idx ));
 LOCAL VOID Read_Resolver_Result PARAMS(( INT r_fd ));
 LOCAL VOID Simple_Message PARAMS(( INT Sock, CHAR *Msg ));
+LOCAL INT Count_Connections PARAMS(( struct sockaddr_in addr ));
 
 LOCAL fd_set My_Listeners;
 LOCAL fd_set My_Sockets;
@@ -119,7 +120,9 @@ Conn_Init( VOID )
 		Log( LOG_EMERG, "Can't allocate memory! [Conn_Init]" );
 		exit( 1 );
 	}
-	Log( LOG_DEBUG, "Allocted connection pool for %d items (%ld bytes).", Pool_Size, sizeof( CONNECTION ) * Pool_Size );
+#ifdef DEBUG
+	Log( LOG_DEBUG, "Allocated connection pool for %d items (%ld bytes).", Pool_Size, sizeof( CONNECTION ) * Pool_Size );
+#endif
 
 	/* zu Beginn haben wir keine Verbindungen */
 	FD_ZERO( &My_Listeners );
@@ -146,7 +149,9 @@ Conn_Exit( VOID )
 	CONN_ID idx;
 	INT i;
 
+#ifdef DEBUG
 	Log( LOG_DEBUG, "Shutting down all connections ..." );
+#endif
 
 #ifdef RENDEZVOUS
 	Rendezvous_UnregisterListeners( );
@@ -164,12 +169,16 @@ Conn_Exit( VOID )
 			if( FD_ISSET( i, &My_Listeners ))
 			{
 				close( i );
+#ifdef DEBUG
 				Log( LOG_DEBUG, "Listening socket %d closed.", i );
+#endif
 			}
 			else if( FD_ISSET( i, &My_Connects ))
 			{
 				close( i );
+#ifdef DEBUG
 				Log( LOG_DEBUG, "Connection %d closed during creation (socket %d).", idx, i );
+#endif
 			}
 			else if( idx < Pool_Size )
 			{
@@ -224,7 +233,9 @@ Conn_ExitListeners( VOID )
 		if( FD_ISSET( i, &My_Sockets ) && FD_ISSET( i, &My_Listeners ))
 		{
 			close( i );
+#ifdef DEBUG
 			Log( LOG_DEBUG, "Listening socket %d closed.", i );
+#endif
 		}
 	}
 } /* Conn_ExitListeners */
@@ -236,6 +247,7 @@ Conn_NewListener( CONST UINT Port )
 	/* Create new listening socket on specified port */
 
 	struct sockaddr_in addr;
+	struct in_addr inaddr;
 	INT sock;
 #ifdef RENDEZVOUS
 	CHAR name[CLIENT_ID_LEN], *info;
@@ -243,9 +255,24 @@ Conn_NewListener( CONST UINT Port )
 
 	/* Server-"Listen"-Socket initialisieren */
 	memset( &addr, 0, sizeof( addr ));
+	memset( &inaddr, 0, sizeof( inaddr ));
 	addr.sin_family = AF_INET;
 	addr.sin_port = htons( Port );
-	addr.sin_addr.s_addr = htonl( INADDR_ANY );
+	if( Conf_ListenAddress[0] )
+	{
+#ifdef HAVE_INET_ATON
+		if( inet_aton( Conf_ListenAddress, &inaddr ) == 0 )
+#else
+		inaddr.s_addr = inet_addr( Conf_ListenAddress );
+		if( inaddr.s_addr == (unsigned)-1 )
+#endif
+		{
+			Log( LOG_CRIT, "Can't listen on %s:%u: can't convert ip address %s!", Conf_ListenAddress, Port, Conf_ListenAddress );
+			return FALSE;
+		}
+	}
+	else inaddr.s_addr = htonl( INADDR_ANY );
+	addr.sin_addr = inaddr;
 
 	/* Socket erzeugen */
 	sock = socket( PF_INET, SOCK_STREAM, 0);
@@ -279,7 +306,8 @@ Conn_NewListener( CONST UINT Port )
 
 	if( sock > Conn_MaxFD ) Conn_MaxFD = sock;
 
-	Log( LOG_INFO, "Now listening on port %d (socket %d).", Port, sock );
+	if( Conf_ListenAddress[0]) Log( LOG_INFO, "Now listening on %s:%d (socket %d).", Conf_ListenAddress, Port, sock );
+	else Log( LOG_INFO, "Now listening on 0.0.0.0:%d (socket %d).", Port, sock );
 
 #ifdef RENDEZVOUS
 	/* Get best server description text */
@@ -349,11 +377,14 @@ Conn_Handler( VOID )
 		/* Check configured servers and established links */
 		Check_Servers( );
 		Check_Connections( );
+
+		t = time( NULL );
 
 		/* noch volle Lese-Buffer suchen */
 		for( i = 0; i < Pool_Size; i++ )
 		{
-			if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].rdatalen > 0 ))
+			if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].rdatalen > 0 ) &&
+			 ( My_Connections[i].delaytime < t ))
 			{
 				/* Kann aus dem Buffer noch ein Befehl extrahiert werden? */
 				if( Handle_Buffer( i )) timeout = FALSE;
@@ -382,7 +413,6 @@ Conn_Handler( VOID )
 		}
 
 		/* von welchen Sockets koennte gelesen werden? */
-		t = time( NULL );
 		read_sockets = My_Sockets;
 		for( i = 0; i < Pool_Size; i++ )
 		{
@@ -413,7 +443,7 @@ Conn_Handler( VOID )
 
 		/* Timeout initialisieren */
 		tv.tv_usec = 0;
-		if( timeout ) tv.tv_sec = TIME_RES;
+		if( timeout ) tv.tv_sec = 1;
 		else tv.tv_sec = 0;
 
 		/* Auf Aktivitaet warten */
@@ -527,7 +557,9 @@ Conn_Write( CONN_ID Idx, CHAR *Data, INT Len )
 	 * In diesem Fall wird hier einfach ein Fehler geliefert. */
 	if( My_Connections[Idx].sock <= NONE )
 	{
+#ifdef DEBUG
 		Log( LOG_DEBUG, "Skipped write on closed socket (connection %d).", Idx );
+#endif
 		return FALSE;
 	}
 
@@ -836,7 +868,9 @@ Handle_Write( CONN_ID Idx )
 
 			return FALSE;
 		}
+#ifdef DEBUG
 		Log( LOG_DEBUG, "Connection %d with \"%s:%d\" established, now sendig PASS and SERVER ...", Idx, My_Connections[Idx].host, Conf_Server[Conf_GetServer( Idx )].port );
+#endif
 
 		/* PASS und SERVER verschicken */
 		Conn_WriteStr( Idx, "PASS %s %s", Conf_Server[Conf_GetServer( Idx )].pwd_out, NGIRCd_ProtoID );
@@ -887,7 +921,7 @@ New_Connection( INT Sock )
 	CONN_ID idx;
 	CLIENT *c;
 	POINTER *ptr;
-	LONG new_size;
+	LONG new_size, cnt;
 
 	assert( Sock > NONE );
 
@@ -915,6 +949,17 @@ New_Connection( INT Sock )
 
 	/* Socket initialisieren */
 	Init_Socket( new_sock );
+	
+	/* Check IP-based connection limit */
+	cnt = Count_Connections( new_addr );
+	if(( Conf_MaxConnectionsIP > 0 ) && ( cnt >= Conf_MaxConnectionsIP ))
+	{
+		/* Access denied, too many connections from this IP! */
+		Log( LOG_ERR, "Refused connection from %s: too may connections (%ld) from this IP!", inet_ntoa( new_addr.sin_addr ), cnt);
+		Simple_Message( new_sock, "ERROR :Connection refused, too many connections from your IP!" );
+		close( new_sock );
+		return;
+	}
 
 	/* Freie Connection-Struktur suchen */
 	for( idx = 0; idx < Pool_Size; idx++ ) if( My_Connections[idx].sock == NONE ) break;
@@ -966,9 +1011,13 @@ New_Connection( INT Sock )
 			/* Struktur umkopieren ... */
 			memcpy( ptr, My_Connections, sizeof( CONNECTION ) * Pool_Size );
 
+#ifdef DEBUG
 			Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [malloc()/memcpy()]", new_size, sizeof( CONNECTION ) * new_size );
+#endif
 		}
+#ifdef DEBUG
 		else Log( LOG_DEBUG, "Allocated new connection pool for %ld items (%ld bytes). [realloc()]", new_size, sizeof( CONNECTION ) * new_size );
+#endif
 
 		/* Adjust pointer to new block */
 		My_Connections = ptr;
@@ -1032,7 +1081,9 @@ Socket2Index( INT Sock )
 	{
 		/* die Connection wurde vermutlich (wegen eines
 		 * Fehlers) bereits wieder abgebaut ... */
+#ifdef DEBUG
 		Log( LOG_DEBUG, "Socket2Index: can't get connection for socket %d!", Sock );
+#endif
 		return NONE;
 	}
 	else return idx;
@@ -1135,6 +1186,9 @@ Handle_Buffer( CONN_ID Idx )
 	result = FALSE;
 	do
 	{
+		/* Check penalty */
+		if( My_Connections[Idx].delaytime > time( NULL )) return result;
+		
 #ifdef USE_ZLIB
 		/* ggf. noch unkomprimiete Daten weiter entpacken */
 		if( My_Connections[Idx].options & CONN_ZIP )
@@ -1214,7 +1268,9 @@ Handle_Buffer( CONN_ID Idx )
 					memcpy( My_Connections[Idx].zip.rbuf, My_Connections[Idx].rbuf, My_Connections[Idx].rdatalen );
 					My_Connections[Idx].zip.rdatalen = My_Connections[Idx].rdatalen;
 					My_Connections[Idx].rdatalen = 0;
+#ifdef DEBUG
 					Log( LOG_DEBUG, "Moved already received data (%d bytes) to uncompression buffer.", My_Connections[Idx].zip.rdatalen );
+#endif
 				}
 			}
 #endif
@@ -1251,14 +1307,18 @@ Check_Connections( VOID )
 				if( My_Connections[i].lastping < time( NULL ) - Conf_PongTimeout )
 				{
 					/* Timeout */
+#ifdef DEBUG
 					Log( LOG_DEBUG, "Connection %d: Ping timeout: %d seconds.", i, Conf_PongTimeout );
+#endif
 					Conn_Close( i, NULL, "Ping timeout", TRUE );
 				}
 			}
 			else if( My_Connections[i].lastdata < time( NULL ) - Conf_PingTimeout )
 			{
 				/* es muss ein PING gesendet werden */
+#ifdef DEBUG
 				Log( LOG_DEBUG, "Connection %d: sending PING ...", i );
+#endif
 				My_Connections[i].lastping = time( NULL );
 				Conn_WriteStr( i, "PING :%s", Client_ID( Client_ThisServer( )));
 			}
@@ -1269,7 +1329,9 @@ Check_Connections( VOID )
 			if( My_Connections[i].lastdata < time( NULL ) - Conf_PingTimeout )
 			{
 				/* Timeout */
+#ifdef DEBUG
 				Log( LOG_DEBUG, "Connection %d timed out ...", i );
+#endif
 				Conn_Close( i, NULL, "Timeout", FALSE );
 			}
 		}
@@ -1325,7 +1387,9 @@ Check_Servers( VOID )
 			Log( LOG_ALERT, "Can't establist server connection: connection limit reached (%d)!", Pool_Size );
 			return;
 		}
+#ifdef DEBUG
 		Log( LOG_DEBUG, "Preparing connection %d for \"%s\" ...", idx, Conf_Server[i].host );
+#endif
 
 		/* Verbindungs-Struktur initialisieren */
 		Init_Conn_Struct( idx );
@@ -1437,7 +1501,9 @@ New_Server( INT Server, CONN_ID Idx )
 	FD_SET( new_sock, &My_Connects );
 	if( new_sock > Conn_MaxFD ) Conn_MaxFD = new_sock;
 
+#ifdef DEBUG
 	Log( LOG_DEBUG, "Registered new connection %d on socket %d.", Idx, My_Connections[Idx].sock );
+#endif
 } /* New_Server */
 
 
@@ -1534,11 +1600,15 @@ Read_Resolver_Result( INT r_fd )
 		/* Opsa! Keine passende Connection gefunden!? Vermutlich
 		 * wurde sie schon wieder geschlossen. */
 		close( r_fd );
+#ifdef DEBUG
 		Log( LOG_DEBUG, "Resolver: Got result for unknown connection!?" );
+#endif
 		return;
 	}
 
+#ifdef DEBUG
 	Log( LOG_DEBUG, "Resolver: %s is \"%s\".", My_Connections[i].host, result );
+#endif
 
 	/* Aufraeumen */
 	close( My_Connections[i].res_stat->pipe[0] );
@@ -1582,4 +1652,18 @@ Simple_Message( INT Sock, CHAR *Msg )
 } /* Simple_Error */
 
 
+LOCAL INT
+Count_Connections( struct sockaddr_in addr_in )
+{
+	INT i, cnt;
+	
+	cnt = 0;
+	for( i = 0; i < Pool_Size; i++ )
+	{
+		if(( My_Connections[i].sock > NONE ) && ( My_Connections[i].addr.sin_addr.s_addr == addr_in.sin_addr.s_addr )) cnt++;
+	}
+	return cnt;
+} /* Count_Connections */
+
+
 /* -eof- */
blob - 57f82b69ad51489d0af0e2c21e54e65c29e26b1a
blob + e4203de4ebabe3e8c31effc7f3c8269521407b83
--- src/ngircd/defines.h
+++ src/ngircd/defines.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: defines.h,v 1.42 2003/02/23 12:03:39 alex Exp $
+ * $Id: defines.h,v 1.42.2.1 2003/11/07 20:51:11 alex Exp $
  *
  * Global defines of ngIRCd.
  */
@@ -19,8 +19,6 @@
 
 #define NONE -1
 
-#define TIME_RES 2			/* Zeit-Aufloesung des Servers in Sekunden */
-
 #define FNAME_LEN 256			/* max. Laenge eines Dateinamen */
 
 #define LINE_LEN 256			/* max. Laenge einer Konfigurationszeile */
blob - ef153f5a53fa60210b095d92015d0c25770a2f5e
blob + 01ec6b68e81e67442fcba56e718a1c9103007c40
--- src/ngircd/irc-info.c
+++ src/ngircd/irc-info.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-info.c,v 1.16.2.1 2003/07/18 20:49:35 alex Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.16.2.2 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -77,6 +77,7 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
 	if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC2_MSG, Client_ID( prefix ), Conf_ServerAdmin2 )) return DISCONNECTED;
 	if( ! IRC_WriteStrClient( Client, RPL_ADMINEMAIL_MSG, Client_ID( prefix ), Conf_ServerAdminMail )) return DISCONNECTED;
 
+	IRC_SetPenalty( Client, 1 );
 	return CONNECTED;
 } /* IRC_ADMIN */
 
@@ -161,7 +162,8 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req )
 		}
 		c = Client_Next( c );
 	}
-
+	
+	IRC_SetPenalty( target, 1 );
 	return IRC_WriteStrClient( target, RPL_ENDOFLINKS_MSG, Client_ID( target ), mask );
 } /* IRC_LINKS */
 
@@ -197,6 +199,7 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req )
 
 	IRC_Send_LUSERS( target );
 
+	IRC_SetPenalty( target, 1 );
 	return CONNECTED;
 } /* IRC_LUSERS */
 
@@ -230,6 +233,7 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
 		}
 	}
 
+	IRC_SetPenalty( from, 3 );
 	return IRC_Show_MOTD( from );
 } /* IRC_MOTD */
 
@@ -324,6 +328,7 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req )
 		if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
 	}
 
+	IRC_SetPenalty( from, 1 );
 	return IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), "*" );
 } /* IRC_NAMES */
 
@@ -402,6 +407,7 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
 			break;
 	}
 
+	IRC_SetPenalty( from, 2 );
 	return IRC_WriteStrClient( from, RPL_ENDOFSTATS_MSG, Client_ID( from ), query );
 } /* IRC_STATS */
 
@@ -517,6 +523,7 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
 	}
 
 	/* mit Versionsinfo antworten */
+	IRC_SetPenalty( Client, 1 );
 #ifdef CVSDATE
 	strlcpy( ver, CVSDATE, sizeof( ver ));
 	strncpy( ver + 4, ver + 5, 2 );
blob - 280923a798856413fef87fa036aeaa20125fe3b2
blob + 223c49e6154c721fe3b0493ae239095553a22b02
--- src/ngircd/irc-login.c
+++ src/ngircd/irc-login.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-login.c,v 1.34 2003/03/31 15:54:21 alex Exp $";
+static char UNUSED id[] = "$Id: irc-login.c,v 1.34.2.1 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -223,6 +223,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 			
 			/* neuen Client-Nick speichern */
 			Client_SetID( target, Req->argv[0] );
+			IRC_SetPenalty( target, 2 );
 		}
 
 		return CONNECTED;
@@ -457,6 +458,9 @@ Hello_User( CLIENT *Client )
 	if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED;
 	if( ! IRC_Show_MOTD( Client )) return DISCONNECTED;
 
+	/* Suspend the client for a second ... */
+	IRC_SetPenalty( Client, 1 );
+
 	return CONNECTED;
 } /* Hello_User */
 
blob - cf6354171df7a454dbd704163b0a146e90673729
blob + fcc1eca552648d5926e4146cc9a83d62b5d02bf4
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.31 2003/01/21 21:04:16 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.31.2.1 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -230,7 +230,8 @@ client_exit:
 		}
 		Log( LOG_DEBUG, "User \"%s\": Mode change, now \"%s\".", Client_Mask( Target ), Client_Modes( Target ));
 	}
-		
+	
+	IRC_SetPenalty( Client, 1 );	
 	return ok;
 } /* Client_Mode */
 
@@ -598,6 +599,7 @@ chan_exit:
 		}
 	}
 
+	IRC_SetPenalty( Client, 1 );
 	return CONNECTED;
 } /* Channel_Mode */
 
blob - b8a5e28d6eaa1095f5291e6c478a09c539638a95
blob + aebea0c9b2c531c37763a3f5a2ada09721f6d2a0
--- src/ngircd/irc-write.c
+++ src/ngircd/irc-write.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-write.c,v 1.14 2002/12/30 17:15:42 alex Exp $";
+static char UNUSED id[] = "$Id: irc-write.c,v 1.14.2.1 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -395,6 +395,21 @@ va_dcl
 } /* IRC_WriteStrRelatedPrefix */
 
 
+GLOBAL VOID
+IRC_SetPenalty( CLIENT *Client, INT Seconds )
+{
+	CONN_ID c;
+	
+	assert( Client != NULL );
+	assert( Seconds > 0 );
+	
+	if( Client_Type( Client ) == CLIENT_SERVER ) return;
+	
+	c = Client_Conn( Client );
+	if( c > NONE ) Conn_SetPenalty( c, Seconds );		
+} /* IRC_SetPenalty */
+
+
 LOCAL CHAR *
 Get_Prefix( CLIENT *Target, CLIENT *Client )
 {
blob - 7d70d696c1b520a9a80b1ecc87717ac0b18f7c43
blob + 24e440c69b24fa105bd29a4e3ebcfd786e439400
--- src/ngircd/irc-write.h
+++ src/ngircd/irc-write.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: irc-write.h,v 1.5 2002/12/12 12:23:43 alex Exp $
+ * $Id: irc-write.h,v 1.5.4.1 2003/11/07 20:51:11 alex Exp $
  *
  * Sending IRC commands over the network (header)
  */
@@ -18,19 +18,21 @@
 #define __irc_write_h__
 
 
-GLOBAL BOOLEAN IRC_WriteStrClient PARAMS((CLIENT *Client, CHAR *Format, ... ));
-GLOBAL BOOLEAN IRC_WriteStrClientPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, CHAR *Format, ... ));
+GLOBAL BOOLEAN IRC_WriteStrClient PARAMS(( CLIENT *Client, CHAR *Format, ... ));
+GLOBAL BOOLEAN IRC_WriteStrClientPrefix PARAMS(( CLIENT *Client, CLIENT *Prefix, CHAR *Format, ... ));
 
-GLOBAL BOOLEAN IRC_WriteStrChannel PARAMS((CLIENT *Client, CHANNEL *Chan, BOOLEAN Remote, CHAR *Format, ... ));
-GLOBAL BOOLEAN IRC_WriteStrChannelPrefix PARAMS((CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... ));
+GLOBAL BOOLEAN IRC_WriteStrChannel PARAMS(( CLIENT *Client, CHANNEL *Chan, BOOLEAN Remote, CHAR *Format, ... ));
+GLOBAL BOOLEAN IRC_WriteStrChannelPrefix PARAMS(( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... ));
 
-GLOBAL VOID IRC_WriteStrServers PARAMS((CLIENT *ExceptOf, CHAR *Format, ... ));
-GLOBAL VOID IRC_WriteStrServersPrefix PARAMS((CLIENT *ExceptOf, CLIENT *Prefix, CHAR *Format, ... ));
-GLOBAL VOID IRC_WriteStrServersPrefixFlag PARAMS((CLIENT *ExceptOf, CLIENT *Prefix, CHAR Flag, CHAR *Format, ... ));
+GLOBAL VOID IRC_WriteStrServers PARAMS(( CLIENT *ExceptOf, CHAR *Format, ... ));
+GLOBAL VOID IRC_WriteStrServersPrefix PARAMS(( CLIENT *ExceptOf, CLIENT *Prefix, CHAR *Format, ... ));
+GLOBAL VOID IRC_WriteStrServersPrefixFlag PARAMS(( CLIENT *ExceptOf, CLIENT *Prefix, CHAR Flag, CHAR *Format, ... ));
 
-GLOBAL BOOLEAN IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... ));
+GLOBAL BOOLEAN IRC_WriteStrRelatedPrefix PARAMS(( CLIENT *Client, CLIENT *Prefix, BOOLEAN Remote, CHAR *Format, ... ));
 
+GLOBAL VOID IRC_SetPenalty PARAMS(( CLIENT *Client, INT Seconds ));
 
+
 #endif
 
 
blob - 2f2874a62993e4a6fdd5a939def845917a78b3f4
blob + 4e95a31ae9a8424365e9e4a80b91756dacb9d244
--- src/ngircd/irc.c
+++ src/ngircd/irc.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc.c,v 1.120.2.1 2003/04/29 12:20:14 alex Exp $";
+static char UNUSED id[] = "$Id: irc.c,v 1.120.2.2 2003/11/07 20:51:11 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -265,6 +265,7 @@ IRC_TRACE( CLIENT *Client, REQUEST *Req )
 	/* Some information about us */
 	if( ! IRC_WriteStrClient( from, RPL_TRACESERVER_MSG, Client_ID( from ), Conf_ServerName, Client_Mask( Client_ThisServer( )), Option_String( Client_Conn( Client )))) return DISCONNECTED;
 
+	IRC_SetPenalty( Client, 3 );
 	return IRC_WriteStrClient( from, RPL_TRACEEND_MSG, Client_ID( from ), Conf_ServerName, PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel );
 } /* IRC_TRACE */
 
@@ -286,6 +287,8 @@ IRC_HELP( CLIENT *Client, REQUEST *Req )
 		if( ! IRC_WriteStrClient( Client, "NOTICE %s :%s", Client_ID( Client ), cmd->name )) return DISCONNECTED;
 		cmd++;
 	}
+	
+	IRC_SetPenalty( Client, 2 );
 	return CONNECTED;
 } /* IRC_HELP */
 
blob - e23e11318499546b8626fe11f0efe35cb2df78ba
blob + 3f87e4b069843258c7e33b308527aa63e7d29c2a
--- src/testsuite/getpid.sh
+++ src/testsuite/getpid.sh
@@ -1,28 +1,35 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: getpid.sh,v 1.2.4.1 2003/04/22 20:01:23 alex Exp $
+# $Id: getpid.sh,v 1.2.4.2 2003/11/07 20:51:11 alex Exp $
 
-# wurde ein Name uebergeben?
+# did we get a name?
 [ $# -ne 1 ] && exit 1
 
-# Flags fuer "ps" ermitteln
+# detect flags for "ps" and "head"
 if [ `uname` = "FreeBSD" ]; then
   PS_FLAGS="-a"; PS_PIDCOL="1"; HEAD_FLAGS="-n 1"
 elif [ `uname` = "A/UX" ]; then
   PS_FLAGS="-ae"; PS_PIDCOL="1"; HEAD_FLAGS="-1"
+elif [ `uname` = "GNU" ]; then
+  PS_FLAGS="-ax"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
 else
   PS_FLAGS="-f"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
   ps $PS_FLAGS > /dev/null 2>&1
   if [ $? -ne 0 ]; then PS_FLAGS="a"; PS_PIDCOL="1"; fi
 fi
 
-# PID ermitteln
+# debug output
+#echo "$0: PS_FLAGS=$PS_FLAGS"
+#echo "$0: PS_PIDCOL=$PS_PIDCOL"
+#echo "$0: HEAD_FLAGS=$HEAD_FLAGS"
+
+# search PID
 ps $PS_FLAGS > procs.tmp
-cat procs.tmp | grep "$1" | awk "{print \$$PS_PIDCOL}" | sort -n > pids.tmp
+cat procs.tmp | grep -v "$0" | grep "$1" | awk "{print \$$PS_PIDCOL}" | sort -n > pids.tmp
 pid=`head $HEAD_FLAGS pids.tmp`
 rm -rf procs.tmp pids.tmp
 
-# ermittelte PID validieren
+# validate PID
 [ "$pid" -gt 1 ] > /dev/null 2>&1
 [ $? -ne 0 ] && exit 1
 
blob - 386106fdde09dc30ae6501bf6a8e37fd2cc45b0c
blob + e74077f5538a3008f24bd9e180f6854f35f95613
--- src/testsuite/ngircd-test.conf
+++ src/testsuite/ngircd-test.conf
@@ -1,4 +1,4 @@
-# $Id: ngircd-test.conf,v 1.3 2002/10/21 13:45:23 alex Exp $
+# $Id: ngircd-test.conf,v 1.3.4.1 2003/11/07 20:51:11 alex Exp $
 
 [Global]
 	Name = ngircd.test.server
@@ -6,6 +6,7 @@
 	Ports = 6789
 	MotdFile = ngircd-test.motd
 	AdminEMail = admin@irc.server
+	MaxConnectionsIP = 0
 
 [Operator]
 	Name = TestOp
blob - b342dedbb4ea4c3182e1181d2c5303c75877f38c
blob + 7252f98c94236e10d2e28ec19682e774e72a3df8
--- src/testsuite/start-server.sh
+++ src/testsuite/start-server.sh
@@ -1,31 +1,37 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: start-server.sh,v 1.10 2002/11/10 14:28:06 alex Exp $
+# $Id: start-server.sh,v 1.10.4.1 2003/11/07 20:51:11 alex Exp $
 
 [ -z "$srcdir" ] && srcdir=`dirname $0`
 
 echo "      starting server ..."
 
-# alte Logfiles loeschen
+# remove old logfiles
 rm -rf logs *.log
 
-# pruefen, ob getpid.sh gueltige PID's liefert. Wenn dem nicht so ist,
-# wird kein ngIRCd gestartet, da dieser ansonsten nicht mehr am Ende
-# des Testlaufs beendet werden koennte!
+# check weather getpid.sh returns valid PIDs. If not, don't start up the
+# test-server, because we won't be able to kill it at the end of the test.
 ./getpid.sh sh > /dev/null 2>&1
 if [ $? -ne 0 ]; then
   echo "      error: getpid.sh FAILED!"
   exit 1
 fi
 
-# MOTD fuer Test-Server erzeugen
+# check if there is a test-server already running
+./getpid.sh T-ngircd > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+  echo "      error: test-server already running!"
+  exit 1
+fi
+
+# generate MOTD for test-server
 echo "This is an ngIRCd Test Server" > ngircd-test.motd
 
-# Test-Server starten ...
+# starting up test-server ...
 ./T-ngircd -np -f ${srcdir}/ngircd-test.conf > ngircd-test.log 2>&1 &
 sleep 1
 
-# validieren, dass Server laeuft
+# validate running test-server
 pid=`./getpid.sh T-ngircd`
 [ -n "$pid" ] && kill -0 $pid > /dev/null 2>&1 || exit 1
 
blob - a9cce99f87760f4a4f44d6c358efeac853dae654
blob + 47aaef62da6c81af86a577ea7bfc5f45fa4790a7
--- src/testsuite/stop-server.sh
+++ src/testsuite/stop-server.sh
@@ -1,17 +1,25 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: stop-server.sh,v 1.9 2002/11/10 14:28:06 alex Exp $
+# $Id: stop-server.sh,v 1.9.4.1 2003/11/07 20:51:11 alex Exp $
 
 [ -z "$srcdir" ] && srcdir=`dirname $0`
 
 echo "      stopping server ..."
 
-# Test-Server stoppen ...
+# stop test-server ...
 pid=`./getpid.sh T-ngircd`
-[ -n "$pid" ] && kill $pid > /dev/null 2>&1 || exit 1
-sleep 1
+if [ -z "$pid" ]; then
+  echo "      no running server found!?"
+  exit 1
+fi
+kill $pid > /dev/null 2>&1 || exit 1
 
-# jetzt duerfte der Prozess nicht mehr laufen
-kill -0 $pid > /dev/null 2>&1 && exit 1 || exit 0
+# waiting ...
+for i in 1 2 3 4 5; do
+  kill -0 $pid > /dev/null 2>&1 || exit 0
+  sleep 1
+done
+echo "      server still running!?"
+exit 1
 
 # -eof-
blob - ed6f6c36c8815fc90042efd5866ecf38093e099e
blob + cab7c1a52cd9cebec2f961f0f9033164ac9f4e72
--- src/testsuite/stress-server.sh
+++ src/testsuite/stress-server.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: stress-server.sh,v 1.6.4.1 2003/04/22 20:01:23 alex Exp $
+# $Id: stress-server.sh,v 1.6.4.2 2003/11/07 20:51:11 alex Exp $
 
 [ -z "$srcdir" ] && srcdir=`dirname $0`
 
@@ -12,11 +12,11 @@ mkdir -p logs tests
 
 type expect > /dev/null 2>&1
 if [ $? -ne 0 ]; then
-  echo "SKIP: ${name} -- \"expect\" not found.";  exit 77
+  echo "      ${name}: \"expect\" not found.";  exit 77
 fi
 type telnet > /dev/null 2>&1
 if [ $? -ne 0 ]; then
-  echo "SKIP: ${name} -- \"telnet\" not found.";  exit 77
+  echo "      ${name}: \"telnet\" not found.";  exit 77
 fi
 
 echo "      stressing server with $CLIENTS clients (be patient!) ..."
blob - 597dd08ce258807beef4984cd53417b86e4004d6
blob + d07c0564eb702f5513a86c2609e56efa9835b01f
--- src/testsuite/tests.sh
+++ src/testsuite/tests.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 # ngIRCd Test Suite
-# $Id: tests.sh,v 1.3 2002/09/12 02:29:03 alex Exp $
+# $Id: tests.sh,v 1.3.6.1 2003/11/07 20:51:11 alex Exp $
 
 name=`basename $0`
 test=`echo ${name} | cut -d '.' -f 1`
@@ -8,11 +8,11 @@ mkdir -p logs
 
 type expect > /dev/null 2>&1
 if [ $? -ne 0 ]; then
-  echo "SKIP: ${name} -- \"expect\" not found.";  exit 77
+  echo "      ${name}: \"expect\" not found.";  exit 77
 fi
 type telnet > /dev/null 2>&1
 if [ $? -ne 0 ]; then
-  echo "SKIP: ${name} -- \"telnet\" not found.";  exit 77
+  echo "      ${name}: \"telnet\" not found.";  exit 77
 fi
 
 echo "      doing ${test} ..."