repo: ngircd
action: commit
revision: 
path_from: 
revision_from: cac9f279fa852c0ececfbf0f7dc09a6f64eff058:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit cac9f279fa852c0ececfbf0f7dc09a6f64eff058
Author: Florian Westphal 
Date:   Sat Jun 4 12:32:09 2005 +0000

    send RFC compliant netsplit messages.

diff --git a/ChangeLog b/ChangeLog
index 8a44b875a1518b5d5d36b4c88f20cc41ca292750..
index ..f34c3f4d7e3af91b0e10afb9ccb8b71ffc8d7275 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@


 ngIRCd CVSHEAD
+  - Make Netsplit Messages RFC compliant.
   - Fix handling of QUIT Messages: send only one message, even if client
     is member of multiple channels.
   - Don't exit server if closing of a socket fails; instead ignore it and
@@ -603,4 +604,4 @@ ngIRCd 0.0.1, 31.12.2001


 -- 
-$Id: ChangeLog,v 1.272 2005/06/04 11:53:24 fw Exp $
+$Id: ChangeLog,v 1.273 2005/06/04 12:32:09 fw Exp $
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 7cb81a7825dd5fd4909f047e86f6914b05ae1920..
index ..faf95a6112a0d25ac8cbe8c152aa7514f97bfcad 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -17,7 +17,7 @@

 #include "portab.h"

-static char UNUSED id[] = "$Id: client.c,v 1.81 2005/05/17 23:18:54 alex Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.82 2005/06/04 12:32:09 fw Exp $";

 #include "imp.h"
 #include 
@@ -214,7 +214,11 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
 	if( ! txt ) txt = "Reason unknown.";

 	/* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
-	if( Client->type == CLIENT_SERVER ) snprintf( msg, sizeof( msg ), "%s: lost server %s", This_Server->id, Client->id );
+	if( Client->type == CLIENT_SERVER ) {
+		strlcpy(msg, This_Server->id, sizeof (msg));
+		strlcat(msg, " ", sizeof (msg));
+		strlcat(msg, Client->id, sizeof (msg));
+	}

 	last = NULL;
 	c = My_Clients;
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index ce6bcaca65da56054eb64017ee12ea41dfeb6af7..
index ..db04a9c33140e51c169d2f6e25c10ebb085d55e0 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -14,7 +14,7 @@

 #include "portab.h"

-static char UNUSED id[] = "$Id: irc-login.c,v 1.43 2005/05/17 23:24:43 alex Exp $";
+static char UNUSED id[] = "$Id: irc-login.c,v 1.44 2005/06/04 12:32:09 fw Exp $";

 #include "imp.h"
 #include 
@@ -382,17 +382,21 @@ GLOBAL bool
 IRC_QUIT( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *target;
+	char quitmsg[LINE_LEN];

 	assert( Client != NULL );
 	assert( Req != NULL );
+		
+	/* Wrong number of arguments? */
+	if( Req->argc > 1 )
+		return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	if (Req->argc == 1)
+		strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);

 	if ( Client_Type( Client ) == CLIENT_SERVER )
 	{
 		/* Server */
-
-		/* Falsche Anzahl Parameter? */
-		if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
 		target = Client_Search( Req->prefix );
 		if( ! target )
 		{
@@ -401,20 +405,21 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
 			return CONNECTED;
 		}

-		if( Req->argc == 0 ) Client_Destroy( target, "Got QUIT command.", NULL, true);
-		else Client_Destroy( target, "Got QUIT command.", Req->argv[0], true);
+		Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);

 		return CONNECTED;
 	}
 	else
 	{
-		/* User, Service, oder noch nicht registriert */
-		
-		/* Falsche Anzahl Parameter? */
-		if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+		if (Req->argc == 1 && quitmsg[0] != '\"') {
+			/* " " to avoid confusion */
+			strlcpy(quitmsg, "\"", sizeof quitmsg);
+			strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
+			strlcat(quitmsg, "\"", sizeof quitmsg );
+		}

-		if( Req->argc == 0 ) Conn_Close( Client_Conn( Client ), "Got QUIT command.", NULL, true);
-		else Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argv[0], true);
+		/* User, Service, oder noch nicht registriert */
+		Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);

 		return DISCONNECTED;
 	}

-----END OF PAGE-----