about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2003-01-13 18:56:30 +0000
committerAlexander Barton <alex@barton.de>2003-01-13 18:56:30 +0000
commit42c4e6c7b19f4ebc1cbf9fb5d8d39407411a8c78 (patch)
tree521a10c2dae32b81c99e4bde1c3048026585d35f
parentf9cb4a42a0b6f0b21af2fde202d6b4e502667be4 (diff)
downloadngircd-42c4e6c7b19f4ebc1cbf9fb5d8d39407411a8c78.tar.gz
ngircd-42c4e6c7b19f4ebc1cbf9fb5d8d39407411a8c78.zip
- Added support for "TRACE" command.
-rw-r--r--src/ngircd/irc.c52
-rw-r--r--src/ngircd/irc.h3
-rw-r--r--src/ngircd/messages.h8
-rw-r--r--src/ngircd/parse.c3
4 files changed, 61 insertions, 5 deletions
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
index f6eda971..7cdb4dad 100644
--- a/src/ngircd/irc.c
+++ b/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- */
diff --git a/src/ngircd/irc.h b/src/ngircd/irc.h
index 6be74bb1..037bcf58 100644
--- a/src/ngircd/irc.h
+++ b/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, REQUEST *Req ));
 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
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index a75a7416..ea2a9ca0 100644
--- a/src/ngircd/messages.h
+++ b/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"
 
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c
index 2ac9cac3..08d47f11 100644
--- a/src/ngircd/parse.c
+++ b/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 },