Commit Diff


commit - f9cb4a42a0b6f0b21af2fde202d6b4e502667be4
commit + 42c4e6c7b19f4ebc1cbf9fb5d8d39407411a8c78
blob - f6eda971f997a818e0621563061203ddee836a75
blob + 7cdb4dadef5431796733e312f9a0ad7c88647142
--- src/ngircd/irc.c
+++ src/ngircd/irc.c
@@ -14,13 +14,17 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc.c,v 1.116 2003/01/08 22:27:13 alex Exp $";
+static char UNUSED id[] = "$Id: irc.c,v 1.117 2003/01/13 18:56:30 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
 
+#include "ngircd.h"
+#include "conn.h"
+#include "resolve.h"
+#include "conf.h"
 #include "conn-func.h"
 #include "client.h"
 #include "channel.h"
@@ -176,4 +180,50 @@ IRC_PRIVMSG( CLIENT *Client, REQUEST *Req )
 } /* IRC_PRIVMSG */
 
 
+GLOBAL BOOLEAN
+IRC_TRACE( CLIENT *Client, REQUEST *Req )
+{
+	CLIENT *from, *target;
+	CONN_ID idx, idx2;
+	CHAR ver[64], *ptr;
+
+	assert( Client != NULL );
+	assert( Req != NULL );
+
+	/* Bad number of arguments? */
+	if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NORECIPIENT_MSG, Client_ID( Client ), Req->command );
+
+	/* Search sender */
+	if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
+	else from = Client;
+	if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
+
+	/* Search target */
+	if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
+	else target = Client_ThisServer( );
+	
+	strlcpy( ver, NGIRCd_VersionAddition( ), sizeof( ver ));
+	ptr = strchr( ver, '-' );
+	if( ptr ) *ptr = '\0';
+
+	/* Forward command to other server? */
+	if( target != Client_ThisServer( ))
+	{
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
+
+		/* Send RPL_TRACELINK back to initiator */
+		idx = Client_Conn( Client ); assert( idx > NONE );
+		idx2 = Client_Conn( Client_NextHop( target )); assert( idx2 > NONE );
+		if( ! IRC_WriteStrClient( from, RPL_TRACELINK_MSG, Client_ID( from ), PACKAGE, VERSION, Client_ID( target ), Client_ID( Client_NextHop( target )), ver, time( NULL ) - Conn_StartTime( idx ), Conn_SendQ( idx ), Conn_SendQ( idx2 ))) return DISCONNECTED;
+
+		/* Forward command */
+		IRC_WriteStrClientPrefix( target, from, "TRACE %s", Req->argv[0] );
+		return CONNECTED;
+	}
+
+	if( ! IRC_WriteStrClient( from, RPL_TRACESERVER_MSG, Client_ID( from ), Conf_ServerName, Client_Mask( Client_ThisServer( )), ver )) return DISCONNECTED;
+	return IRC_WriteStrClient( from, RPL_TRACEEND_MSG, Client_ID( from ), Conf_ServerName, PACKAGE, VERSION, NGIRCd_DebugLevel );
+} /* IRC_TRACE */
+
+
 /* -eof- */
blob - 6be74bb151b22c7e60f743a774f597fe62af89f2
blob + 037bcf5890cd7f6c208d5ff121f82dc0b26f3ff7
--- src/ngircd/irc.h
+++ src/ngircd/irc.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: irc.h,v 1.36 2002/12/12 12:23:43 alex Exp $
+ * $Id: irc.h,v 1.37 2003/01/13 18:56:30 alex Exp $
  *
  * IRC commands (header)
  */
@@ -22,6 +22,7 @@ GLOBAL BOOLEAN IRC_ERROR PARAMS(( CLIENT *Client, REQU
 GLOBAL BOOLEAN IRC_KILL PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL BOOLEAN IRC_NOTICE PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL BOOLEAN IRC_PRIVMSG PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_TRACE PARAMS(( CLIENT *Client, REQUEST *Req ));
 
 
 #endif
blob - a75a74163ae3939bbad2ec0a565999d62e0c3e39
blob + ea2a9ca0241afaa808c93ec561d6d021a7f00c6b
--- src/ngircd/messages.h
+++ src/ngircd/messages.h
@@ -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
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: messages.h,v 1.62 2003/01/02 17:55:28 alex Exp $
+ * $Id: messages.h,v 1.63 2003/01/13 18:56:30 alex Exp $
  *
  * IRC numerics (Header)
  */
@@ -23,6 +23,9 @@
 #define RPL_CREATED_MSG			"003 %s :This server has been started %s"
 #define RPL_MYINFO_MSG			"004 %s %s ngircd-%s %s %s"
 #define RPL_ISUPPORT_MSG		"005 %s NICKLEN=%d TOPICLEN=%d AWAYLEN=%d MAXCHANNELS=%d :are supported on this server"
+
+#define RPL_TRACELINK_MSG		"200 %s Link %s-%s %s %s V%s %ld %d %d"
+#define RPL_TRACESERVER_MSG		"206 %s Serv 1 0S 0C %s %s :V%s"
 #define RPL_STATSLINKINFO_MSG		"211 %s %s %d %ld %ld %ld %ld :%ld"
 #define RPL_STATSCOMMANDS_MSG		"212 %s %s %ld %ld %ld"
 #define RPL_ENDOFSTATS_MSG		"219 %s %c :End of STATS report"
@@ -36,6 +39,7 @@
 #define RPL_ADMINLOC1_MSG		"257 %s :%s"
 #define RPL_ADMINLOC2_MSG		"258 %s :%s"
 #define RPL_ADMINEMAIL_MSG		"259 %s :%s"
+#define RPL_TRACEEND_MSG		"262 %s %s %s-%s.%s :End of TRACE"
 #define RPL_LOCALUSERS_MSG		"265 %s :Current local users: %ld, Max: %ld"
 #define RPL_NETUSERS_MSG		"266 %s :Current global users: %ld, Max: %ld"
 
blob - 2ac9cac33c1b4432c90892aa003de36dadacc4ca
blob + 08d47f11494a96c9780d7314b5f800c2143375ff
--- src/ngircd/parse.c
+++ src/ngircd/parse.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: parse.c,v 1.57 2003/01/12 22:18:46 alex Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.58 2003/01/13 18:56:30 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -84,6 +84,7 @@ COMMAND My_Commands[] =
 	{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "TOPIC", IRC_TOPIC, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "TRACE", IRC_TRACE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "USER", IRC_USER, 0xFFFF, 0, 0, 0 },
 	{ "USERHOST", IRC_USERHOST, CLIENT_USER, 0, 0, 0 },
 	{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },