Commit Diff


commit - 6cfc56064e25b5bb54fb1f9503820a7e38846303
commit + 530112b114ffa7d5352c0733790ddf90253f41f9
blob - 665d2993d12444352ea055a2d31a70b39807c3c5
blob + 8fa83a7b71a3dcc3512eb4c64537751e105e68ce
--- ChangeLog
+++ ChangeLog
@@ -10,6 +10,11 @@
                                -- ChangeLog --
 
 
+ngIRCd-dev
+
+  - Add support for modeless channels ("+channels").
+    (Bryan Caldwell, Ali Shemiran)
+
 ngIRCd 0.12.0-pre2 (2008-04-29)
 
   - IPv6: Add config options to disabe ipv4/ipv6 support.
blob - 32f911a200f6269eed0f51420a8523ea980c0b78
blob + 7859238b447e2844b2c6cbcf8b38057362b20753
--- src/ngircd/channel.c
+++ src/ngircd/channel.c
@@ -480,7 +480,16 @@ Channel_IsValidName( const char *Name )
 {
 	assert( Name != NULL );
 
-	if(( Name[0] != '#' ) || ( strlen( Name ) >= CHANNEL_NAME_LEN )) return false;
+	switch (Name[0]) {
+		case '#': break;
+#ifndef STRICT_RFC
+		case '+': /* modeless channel */
+		break;
+#endif
+		default: return false;
+	}
+	if (strlen(Name) >= CHANNEL_NAME_LEN)
+		return false;
 
 	return Name[strcspn(Name, " ,:\007")] == 0;
 } /* Channel_IsValidName */
@@ -892,7 +901,7 @@ Remove_Client( int Type, CHANNEL *Chan, CLIENT *Client
 				IRC_WriteStrClientPrefix(Client, Origin, "KICK %s %s :%s",
 								c->name, Client_ID( Client ), Reason);
 			}
-			LogDebug("User \"%s\" has been kicked of \"%s\" by \"%s\": %s.",
+			LogDebug("User \"%s\" has been kicked off \"%s\" by \"%s\": %s.",
 				Client_Mask( Client ), c->name, Client_ID(Origin), Reason);
 			break;
 		default: /* PART */
blob - c678ceeb3f4160a933c6e845ed427e45c7aff70c
blob + 3f76452e48f93fafdf5a68b67686476d649e78fa
--- src/ngircd/irc-channel.c
+++ src/ngircd/irc-channel.c
@@ -239,9 +239,15 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 			if ((Conf_MaxJoins > 0) && (Channel_CountForUser(Client) >= Conf_MaxJoins))
 				return IRC_WriteStrClient(Client, ERR_TOOMANYCHANNELS_MSG,
 							Client_ID(Client), channame);
-			if (!chan) /* New Channel: first user will be channel operator */
-				flags = "o";
-			else
+			if (!chan) {
+				/*
+				 * New Channel: first user will be channel operator
+				 * unless this is a modeless channel... */
+#ifndef STRICT_RFC
+				if (*channame != '+')
+#endif
+					flags = "o";
+			} else
 				if (!join_allowed(Client, target, chan, channame, key))
 					break;
 		} else {
@@ -257,8 +263,14 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
 		if (!Channel_Join(target, channame))
 			break;
 
-		if (!chan) /* channel is new; it has been created above */
+		if (!chan) { /* channel is new; it has been created above */
 			chan = Channel_Search(channame);
+			assert(chan != NULL);
+			if (*channame == '+') { /* modeless channel... */
+				Channel_ModeAdd(chan, 't'); /* /TOPIC not allowed */
+				Channel_ModeAdd(chan, 'n'); /* no external msgs */
+			}
+		}
 		assert(chan != NULL);
 
 		join_set_channelmodes(chan, target, flags);
@@ -333,8 +345,8 @@ IRC_TOPIC( CLIENT *Client, REQUEST *Req )
 	assert( Client != NULL );
 	assert( Req != NULL );
 
-	/* Falsche Anzahl Parameter? */
-	if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+	if ((Req->argc < 1) || (Req->argc > 2))
+		return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
 
 	if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
 	else from = Client;
blob - 3786e3994593c53aa41c4e3d067190a136a61ee1
blob + 3bf809bc0968adc90fa18edc4a4c053d85674395
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
@@ -286,6 +286,12 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Or
 	long l;
 	size_t len;
 
+#ifndef STRICT_RFC
+	/* Are modes allowed on channel? */
+	if (Channel_Name(Channel)[0] == '+')
+		return IRC_WriteStrClient(Client, ERR_NOCHANMODES_MSG,
+				Client_ID(Client), Channel_Name(Channel));
+#endif
 	/* Mode request: let's answer it :-) */
 	if (Req->argc <= 1)
 		return Channel_Mode_Answer_Request(Origin, Channel);
blob - 4f01ac5e4ccdad96e7d922fd8869fdbafc020bfb
blob + b42e38beb2c08ca0fd1adbfc9208530b854c60ae
--- src/ngircd/messages.h
+++ src/ngircd/messages.h
@@ -114,6 +114,7 @@
 #define ERR_INVITEONLYCHAN_MSG		"473 %s %s :Cannot join channel (+i)"
 #define ERR_BANNEDFROMCHAN_MSG		"474 %s %s :Cannot join channel (+b)"
 #define ERR_BADCHANNELKEY_MSG		"475 %s %s :Cannot join channel (+k)"
+#define ERR_NOCHANMODES_MSG		"477 %s %s :Channel doesn't support modes"
 #define ERR_NOPRIVILEGES_MSG		"481 %s :Permission denied"
 #define ERR_CHANOPRIVSNEEDED_MSG	"482 %s %s :You are not channel operator"
 #define ERR_CANTKILLSERVER_MSG		"483 %s :You can't kill a server!"
blob - 6512aaae337713ac9f7a79f3bacd0b83e73673a4
blob + bc8df8442deb534d61a6f4f25ad3c21397249904
--- src/testsuite/Makefile.am
+++ src/testsuite/Makefile.am
@@ -21,6 +21,7 @@ EXTRA_DIST = \
 	start-server.sh stop-server.sh tests.sh stress-server.sh \
 	test-loop.sh wait-tests.sh \
 	channel-test.e connect-test.e check-idle.e misc-test.e mode-test.e \
+	opless-channel-test.e \
 	who-test.e stress-A.e stress-B.e \
 	ngircd-test.conf
 
@@ -47,6 +48,10 @@ channel-test: tests.sh
 	rm -f channel-test
 	ln -s $(srcdir)/tests.sh channel-test
 
+opless-channel-test: tests.sh
+	rm -f opless-channel-test
+	ln -s $(srcdir)/tests.sh opless-channel-test
+
 who-test: tests.sh
 	rm -f who-test
 	ln -s $(srcdir)/tests.sh who-test
@@ -65,6 +70,7 @@ TESTS = start-server.sh \
 	misc-test \
 	mode-test \
 	who-test \
+	opless-channel-test \
 	stress-server.sh \
 	stop-server.sh
 
blob - /dev/null
blob + 35d109e9be4d903e0a886c7d81ca434e4c67ea2d (mode 644)
--- /dev/null
+++ src/testsuite/opless-channel-test.e
@@ -0,0 +1,32 @@
+spawn telnet localhost 6789
+expect {
+       timeout { exit 1 }
+       "Connected"
+}
+
+send "nick nick\r"
+send "user user . . :User\r"
+expect {
+       timeout { exit 1 }
+       "376"
+}
+
+send "JOIN +Channel\r"
+expect {
+       timeout { exit 1 }
+       "@* JOIN :+Channel"
+}
+
+send "mode +Channel +t\r"
+expect {
+       timeout { exit 1 }
+       "477"
+}
+
+send "quit\r"
+expect {
+       timeout { exit 1 }
+       "Connection closed"
+}
+
+# -eof-