]> PatchyGit - patchyircd.git/commitdiff
check channel key and member limit
authorEgor <egor@patchysicp.xyz>
Sun, 8 May 2022 11:06:11 +0000 (14:06 +0300)
committerEgor <egor@patchysicp.xyz>
Sun, 8 May 2022 12:49:01 +0000 (15:49 +0300)
irc.c

diff --git a/irc.c b/irc.c
index e4768b8..4cab9fa 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -871,7 +871,6 @@ void channel_sendnames(struct client_data *client, struct channel *chan)
 }
 void channel_join(struct client_data *client, const char *channel, const char *chankey)
 {
-       (void)chankey;
        // TODO: check channel limit?
        if (channel[0] != '#' && channel[0] != '&')
                return; // FIXME: error
@@ -901,12 +900,16 @@ void channel_join(struct client_data *client, const char *channel, const char *c
        } else {
                if (trie_get(&chan->members, client->key))
                        return;
-               // TODO: check key
-               // TODO: check limit
-               // TODO: check ban
-               // TODO: check ban exemption
-               // TODO: check invite
-               // TODO: check invite exemption
+               if (!(client->umode & UMODE_OPER)) {
+                       if (chan->chankey && (!chankey || strcmp(chan->chankey, chankey) == 0))
+                               return; // error 475
+                       if (chan->member_limit != -1 && chan->member_count >= chan->member_limit)
+                               return; // error 471
+                       // TODO: check ban
+                       // TODO: check ban exemption
+                       // TODO: check invite
+                       // TODO: check invite exemption
+               }
        }
        if (trie_set(&chan->members, client->key, client, NULL) == -1)
                abort();