about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2008-08-13 16:52:35 +0200
committerAlexander Barton <alex@barton.de>2008-09-23 11:47:17 +0200
commit6bc2d3d06e9cb4da68ea4b63d9b6b219d88ab927 (patch)
tree0c987897a483bb1dbc4ff6c90f3e6c74e8a67d86
parenta5735f68d7dd8cc7b106e0183b44002785dd8425 (diff)
downloadngircd-6bc2d3d06e9cb4da68ea4b63d9b6b219d88ab927.tar.gz
ngircd-6bc2d3d06e9cb4da68ea4b63d9b6b219d88ab927.zip
New connection option CONN_RFC1459.
This new connection option CONN_RFC1459 indicates that the peer on this
link only supports the IRC protocol as defined in RFC 1459 and that the
compatibility mode (e. g. for outgoing commands like NICK) should be used.
-rw-r--r--src/ngircd/conn.h8
-rw-r--r--src/ngircd/irc-login.c12
2 files changed, 15 insertions, 5 deletions
diff --git a/src/ngircd/conn.h b/src/ngircd/conn.h
index cbfcc8f1..08f6dde0 100644
--- a/src/ngircd/conn.h
+++ b/src/ngircd/conn.h
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 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,8 +8,6 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conn.h,v 1.46 2008/02/26 22:04:17 fw Exp $
- *
  * Connection management (header)
  */
 
@@ -23,9 +21,9 @@
 
 #define CONN_ISCLOSING		1	/* Conn_Close() already called */
 #define CONN_ISCONNECTING	2	/* connect() in progress */
-
+#define CONN_RFC1459		4	/* RFC 1459 compatibility mode */
 #ifdef ZLIB
-#define CONN_ZIP		4	/* zlib compressed link */
+#define CONN_ZIP		8	/* zlib compressed link */
 #endif
 
 #include "conf-ssl.h"
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 4a2ebe22..82e3482a 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -168,6 +168,7 @@ GLOBAL bool
 IRC_NICK( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *intr_c, *target, *c;
+	CONN_ID conn;
 	char *nick, *user, *hostname, *modes, *info;
 	int token, hops;
 
@@ -305,6 +306,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 						  Client_ID(Client), Req->command);
 
 		if (Req->argc >= 7) {
+			/* RFC 2813 compatible syntax */
 			nick = Req->argv[0];
 			hops = atoi(Req->argv[1]);
 			user = Req->argv[2];
@@ -313,6 +315,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 			modes = Req->argv[5] + 1;
 			info = Req->argv[6];
 		} else {
+			/* RFC 1459 compatible syntax */
 			nick = Req->argv[0];
 			hops = 1;
 			user = Req->argv[0];
@@ -320,6 +323,15 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 			token = atoi(Req->argv[1]);
 			modes = "";
 			info = Req->argv[0];
+
+			conn = Client_Conn(Client);
+			if (conn != NONE &&
+			    !(Conn_Options(conn) & CONN_RFC1459)) {
+				Log(LOG_INFO,
+				    "Switching connection %d (\"%s\") to RFC 1459 compatibility mode.",
+				    conn, Client_ID(Client));
+				Conn_SetOption(conn, CONN_RFC1459);
+			}
 		}
 
 		/* Nick ueberpruefen */