]> arthur.barton.de Git - ngircd.git/commitdiff
Make sure that the target user is able to join a local channel
authorAlexander Barton <alex@barton.de>
Sun, 12 Apr 2015 18:59:43 +0000 (20:59 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 12 Apr 2015 18:59:43 +0000 (20:59 +0200)
Implement ERR_USERNOTONSERV(504) numeric and make sure that the
target user is on the same server when inviting other users to
local ("&") channels.

ircd-ratbox uses the ERR_USERNOTONSERV(504) numeric for this, and I
think this is a good idea -- other IRC daemons (like ircu) silently
drop such impossible invites, but thats not a big benefit ...

Idea by Cahata, thanks! Closes #183.

src/ngircd/irc-op.c
src/ngircd/messages.h

index b75841a805345549b3cb3a247165359b6a0ae5f7..2e5c680aaa52ddde65b6a0ade839e90e96770cdb 100644 (file)
@@ -150,6 +150,14 @@ IRC_INVITE(CLIENT *Client, REQUEST *Req)
                return IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
                                          Client_ID(Client), Req->argv[0]);
 
+       if (Req->argv[1][0] == '&') {
+               /* Local channel. Make sure the target user is on this server! */
+               if (Client_Conn(target) == NONE)
+                       return IRC_WriteErrClient(from, ERR_USERNOTONSERV_MSG,
+                                                 Client_ID(Client),
+                                                 Req->argv[0]);
+       }
+
        chan = Channel_Search(Req->argv[1]);
        if (chan) {
                /* Channel exists. Is the user a valid member of the channel? */
index 75c67b0b0b675c73c1addcc49a1f46c80cb7a7cd..a5bc2c7ae8a90daea955bc2cceedcd0867387fb9 100644 (file)
 #define ERR_UMODEUNKNOWNFLAG_MSG       "501 %s :Unknown mode"
 #define ERR_UMODEUNKNOWNFLAG2_MSG      "501 %s :Unknown mode \"%c%c\""
 #define ERR_USERSDONTMATCH_MSG         "502 %s :Can't set/get mode for other users"
+#define ERR_USERNOTONSERV_MSG          "504 %s %s :User is not on this server"
 #define ERR_NOINVITE_MSG               "518 %s :Cannot invite to %s (+V)"
 
 #ifdef ZLIB