Add support for modeless channels (+channels).
[fw@strlen.de:
- integrate test cases
- don't support +channels when compiled with --strict-rfc
- do not set +o mode for channel creator
- force +nt mode when channel is created ]
-- 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.
{
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 */
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 */
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 {
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);
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;
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);
#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!"
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
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
misc-test \
mode-test \
who-test \
+ opless-channel-test \
stress-server.sh \
stop-server.sh
--- /dev/null
+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-