summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2008-02-17 13:26:41 +0000
committerFlorian Westphal <fw@strlen.de>2008-02-26 23:49:33 +0100
commitddecfcd8310f77974803c9c67431809320646a55 (patch)
tree5828be71a1718a170a0b8873561cd7c0a7d5a76f /src
parent2f71fbb2a1319d1b0aca4c9564c2e51a88b4a578 (diff)
downloadngircd-ddecfcd8310f77974803c9c67431809320646a55.tar.gz
ngircd-ddecfcd8310f77974803c9c67431809320646a55.zip
Implemented IRC commands INFO, USERS (dummy), and SUMMON (dummy).
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-info.c92
-rw-r--r--src/ngircd/irc-info.h5
-rw-r--r--src/ngircd/messages.h6
-rw-r--r--src/ngircd/parse.c5
-rw-r--r--src/testsuite/Makefile.am14
-rw-r--r--src/testsuite/misc-test.e50
6 files changed, 163 insertions, 9 deletions
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index 7878c5d4..87ed2ad0 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-info.c,v 1.43 2008/02/17 00:00:12 fw Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.44 2008/02/17 13:26:42 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -85,6 +85,71 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
 } /* IRC_ADMIN */
 
 
+/**
+ * Handler for the IRC command "INFO".
+ * See RFC 2812 section 3.4.10.
+ */
+GLOBAL bool
+IRC_INFO(CLIENT * Client, REQUEST * Req)
+{
+	CLIENT *target, *prefix;
+	char msg[510];
+
+	assert(Client != NULL);
+	assert(Req != NULL);
+
+	/* Wrong number of parameters? */
+	if (Req->argc > 1)
+		return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+					  Client_ID(Client), Req->command);
+
+	/* Determine prefix */
+	if (Client_Type(Client) == CLIENT_SERVER)
+		prefix = Client_Search(Req->prefix);
+	else
+		prefix = Client;
+	if (!prefix)
+		return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
+					  Client_ID(Client), Req->prefix);
+
+	/* Look for a target */
+	if (Req->argc > 0)
+		target = Client_Search(Req->argv[0]);
+	else
+		target = Client_ThisServer();
+	
+	/* Make sure that the target is a server */
+	if (target && Client_Type(target) != CLIENT_SERVER)
+		target = Client_Introducer(target);
+
+	if (!target)
+		return IRC_WriteStrClient(prefix, ERR_NOSUCHSERVER_MSG,
+					  Client_ID(prefix), Req->argv[0]);
+
+	/* Pass on to another server? */
+	if (target != Client_ThisServer()) {
+		IRC_WriteStrClientPrefix(target, prefix, "INFO %s",
+					 Req->argv[0]);
+		return CONNECTED;
+	}
+
+	if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix),
+				NGIRCd_Version))
+		return DISCONNECTED;
+	
+	strlcpy(msg, "Server has been started ", sizeof(msg));
+	strlcat(msg, NGIRCd_StartStr, sizeof(msg));
+	if (!IRC_WriteStrClient(Client, RPL_INFO_MSG, Client_ID(prefix), msg))
+		return DISCONNECTED;
+
+	if (!IRC_WriteStrClient(Client, RPL_ENDOFINFO_MSG, Client_ID(prefix)))
+		return DISCONNECTED;
+
+	IRC_SetPenalty(Client, 2);
+	return CONNECTED;
+} /* IRC_INFO */
+
+
 GLOBAL bool
 IRC_ISON( CLIENT *Client, REQUEST *Req )
 {
@@ -469,6 +534,19 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
 } /* IRC_STATS */
 
 
+/**
+ * Handler for the IRC command "SUMMON".
+ * See RFC 2812 section 4.5. ngIRCd doesn't implement this functionality and
+ * therefore answers with ERR_SUMMONDISABLED.
+ */
+GLOBAL bool
+IRC_SUMMON(CLIENT * Client, REQUEST * Req)
+{
+	return IRC_WriteStrClient(Client, ERR_SUMMONDISABLED_MSG,
+				  Client_ID(Client), Req->command);
+} /* IRC_SUMMON */
+
+
 GLOBAL bool
 IRC_TIME( CLIENT *Client, REQUEST *Req )
 {
@@ -546,6 +624,18 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req )
 } /* IRC_USERHOST */
 
 
+/**
+ * Handler for the IRC command "USERS".
+ * See RFC 2812 section 4.6. As suggested there the command is disabled.
+ */
+GLOBAL bool
+IRC_USERS(CLIENT * Client, REQUEST * Req)
+{
+	return IRC_WriteStrClient(Client, ERR_USERSDISABLED_MSG,
+				  Client_ID(Client), Req->command);
+} /* IRC_USERS */
+
+
 GLOBAL bool
 IRC_VERSION( CLIENT *Client, REQUEST *Req )
 {
diff --git a/src/ngircd/irc-info.h b/src/ngircd/irc-info.h
index 1aff85bf..faef75ad 100644
--- a/src/ngircd/irc-info.h
+++ b/src/ngircd/irc-info.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: irc-info.h,v 1.5 2008/02/11 11:06:31 fw Exp $
+ * $Id: irc-info.h,v 1.6 2008/02/17 13:26:42 alex Exp $
  *
  * IRC info commands (header)
  */
@@ -19,14 +19,17 @@
 
 
 GLOBAL bool IRC_ADMIN PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL bool IRC_INFO PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_ISON PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_LINKS PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_LUSERS PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_MOTD PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_NAMES PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_STATS PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL bool IRC_SUMMON PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_TIME PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_USERHOST PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL bool IRC_USERS PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_VERSION PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_WHO PARAMS(( CLIENT *Client, REQUEST *Req ));
 GLOBAL bool IRC_WHOIS PARAMS(( CLIENT *Client, REQUEST *Req ));
diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
index ccf9aa09..4f01ac5e 100644
--- a/src/ngircd/messages.h
+++ b/src/ngircd/messages.h
@@ -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.74 2007/12/11 11:29:44 fw Exp $
+ * $Id: messages.h,v 1.75 2008/02/17 13:26:42 alex Exp $
  *
  * IRC numerics (Header)
  */
@@ -77,6 +77,8 @@
 #define RPL_BANLIST_MSG			"367 %s %s %s"
 #define RPL_ENDOFBANLIST_MSG		"368 %s %s :End of channel ban list"
 #define RPL_ENDOFWHOWAS_MSG		"369 %s %s :End of WHOWAS list"
+#define RPL_INFO_MSG    		"371 %s :%s"
+#define RPL_ENDOFINFO_MSG    		"374 %s :End of INFO list"
 #define RPL_MOTD_MSG			"372 %s :- %s"
 #define RPL_MOTDSTART_MSG		"375 %s :- %s message of the day"
 #define RPL_ENDOFMOTD_MSG		"376 %s :End of MOTD command"
@@ -100,6 +102,8 @@
 #define ERR_USERNOTINCHANNEL_MSG	"441 %s %s %s :They aren't on that channel"
 #define ERR_NOTONCHANNEL_MSG		"442 %s %s :You are not on that channel"
 #define ERR_USERONCHANNEL_MSG		"443 %s %s %s :is already on channel"
+#define ERR_SUMMONDISABLED_MSG		"445 %s %s :SUMMON has been disabled"
+#define ERR_USERSDISABLED_MSG		"446 %s %s :USERS has been disabled"
 #define ERR_NOTREGISTERED_MSG		"451 %s :Connection not registered"
 #define ERR_NOTREGISTEREDSERVER_MSG	"451 %s :Connection not registered as server link"
 #define ERR_NEEDMOREPARAMS_MSG		"461 %s %s :Syntax error"
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c
index 31ac99f5..5cfeaaa8 100644
--- a/src/ngircd/parse.c
+++ b/src/ngircd/parse.c
@@ -12,7 +12,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: parse.c,v 1.71 2008/02/05 13:07:14 fw Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.72 2008/02/17 13:26:42 alex Exp $";
 
 /**
  * @file
@@ -67,6 +67,7 @@ static COMMAND My_Commands[] =
 	{ "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 0, 0, 0 },
 	{ "ERROR", IRC_ERROR, 0xFFFF, 0, 0, 0 },
 	{ "HELP", IRC_HELP, CLIENT_USER, 0, 0, 0 },
+	{ "INFO", IRC_INFO, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "INVITE", IRC_INVITE, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "ISON", IRC_ISON, CLIENT_USER, 0, 0, 0 },
 	{ "JOIN", IRC_JOIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -93,11 +94,13 @@ static COMMAND My_Commands[] =
 	{ "SERVER", IRC_SERVER, 0xFFFF, 0, 0, 0 },
 	{ "SQUIT", IRC_SQUIT, CLIENT_SERVER, 0, 0, 0 },
 	{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
+	{ "SUMMON", IRC_SUMMON, 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 },
+	{ "USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
 	{ "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am
index 6ea9597c..6512aaae 100644
--- a/src/testsuite/Makefile.am
+++ b/src/testsuite/Makefile.am
@@ -9,7 +9,7 @@
 # Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #
-# $Id: Makefile.am,v 1.17 2008/02/17 00:00:13 fw Exp $
+# $Id: Makefile.am,v 1.18 2008/02/17 13:26:42 alex Exp $
 #
 
 AUTOMAKE_OPTIONS = ../portab/ansi2knr
@@ -20,9 +20,8 @@ EXTRA_DIST = \
 	README functions.inc getpid.sh \
 	start-server.sh stop-server.sh tests.sh stress-server.sh \
 	test-loop.sh wait-tests.sh \
-	connect-test.e channel-test.e mode-test.e \
-	who-test.e
-	stress-A.e stress-B.e check-idle.e \
+	channel-test.e connect-test.e check-idle.e misc-test.e mode-test.e \
+	who-test.e stress-A.e stress-B.e \
 	ngircd-test.conf
 
 all:
@@ -52,6 +51,10 @@ who-test: tests.sh
 	rm -f who-test
 	ln -s $(srcdir)/tests.sh who-test
 
+misc-test: tests.sh
+	rm -f misc-test
+	ln -s $(srcdir)/tests.sh misc-test
+
 mode-test: tests.sh
 	rm -f mode-test
 	ln -s $(srcdir)/tests.sh mode-test
@@ -59,8 +62,9 @@ mode-test: tests.sh
 TESTS = start-server.sh \
 	connect-test \
 	channel-test \
-	who-test \
+	misc-test \
 	mode-test \
+	who-test \
 	stress-server.sh \
 	stop-server.sh
 
diff --git a/src/testsuite/misc-test.e b/src/testsuite/misc-test.e
new file mode 100644
index 00000000..5c985f55
--- /dev/null
+++ b/src/testsuite/misc-test.e
@@ -0,0 +1,50 @@
+# $Id: misc-test.e,v 1.1 2008/02/17 13:26:42 alex Exp $
+
+spawn telnet localhost 6789
+expect {
+	timeout { exit 1 }
+	"Connected"
+}
+
+send "nick nick\r"
+send "user user . . :User\r"
+expect {
+	timeout { exit 1 }
+	"376"
+}
+
+send "summon\r"
+expect {
+	timeout { exit 1 }
+	"445"
+}
+
+send "users\r"
+expect {
+	timeout { exit 1 }
+	"446"
+}
+
+send "info\r"
+expect {
+	timeout { exit 1 }
+	"371"
+}
+expect {
+	timeout { exit 1 }
+	"374"
+}
+
+send "squit\r"
+expect {
+	timeout { exit 1 }
+	"481"
+}
+
+send "quit\r"
+expect {
+	timeout { exit 1 }
+	"ERROR"
+}
+
+# -eof-