Folks, The students in my software-engineering class are writing IRC clients in Java, and I'm running ngIRCd as a sandbox for them to play in. We noticed ngIRCd doesn't obey the "JOIN 0" command specified in RFC 2812: JOIN 0 ; Leave all currently joined channels. http://tools.ietf.org/html/rfc2812#section-3.2.1 I believe the following patch addresses this. Cheers! -- Dana Dahlstrom Lecturer, Computer Science and Engineering University of California, San Diego (Remember, reality is only an approximation of theory.) Index: src/ngircd/irc-channel.c =================================================================== RCS file: /srv/cvs/ngircd/ngircd/src/ngircd/irc-channel.c,v retrieving revision 1.41 diff -u -p -r1.41 irc-channel.c --- src/ngircd/irc-channel.c 7 Jan 2008 11:42:00 -0000 1.41 +++ src/ngircd/irc-channel.c 5 Feb 2008 05:53:11 -0000 @@ -46,6 +46,7 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) char *channame, *channame_ptr, *key, *key_ptr, *flags, *topic, modes[8]; bool is_new_chan, is_invited, is_banned; CLIENT *target; + CL2CHAN *cl2chan; CHANNEL *chan; assert( Client != NULL ); @@ -61,6 +62,23 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) else target = Client; if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); + /* Is argument "0"? */ + if (Req->argc == 1 && !strncmp("0", Req->argv[0], 2)) { + + /* Part from all channels. */ + cl2chan = Channel_FirstChannelOf( target ); + while (cl2chan) + { + chan = Channel_GetChannel( cl2chan ); + assert( chan != NULL ); + Channel_Part( target, Client, Channel_Name( chan ), Client_ID( target )); + + /* next */ + cl2chan = Channel_FirstChannelOf( target ); + } + return CONNECTED; + } + /* Are channel keys given? */ if (Req->argc > 1) { key = Req->argv[1]; Index: src/testsuite/channel-test.e =================================================================== RCS file: /srv/cvs/ngircd/ngircd/src/testsuite/channel-test.e,v retrieving revision 1.3 diff -u -p -r1.3 channel-test.e --- src/testsuite/channel-test.e 27 Dec 2003 13:01:12 -0000 1.3 +++ src/testsuite/channel-test.e 5 Feb 2008 05:53:11 -0000 @@ -69,6 +69,36 @@ expect { "@* PART #channel :nick" } +send "join #channel\r" +expect { + timeout { exit 1 } + "@* JOIN :#channel" +} +expect { + timeout { exit 1 } + "366" +} + +send "join #channel2\r" +expect { + timeout { exit 1 } + "@* JOIN :#channel2" +} +expect { + timeout { exit 1 } + "366" +} + +send "join 0\r" +expect { + timeout { exit 1 } + "@* PART #channel2 :nick" +} +expect { + timeout { exit 1 } + "@* PART #channel :nick" +} + send "quit\r" expect { timeout { exit 1 }