]> PatchyGit - patchyircd.git/commitdiff
add extra nick reservations
authorEgor <egor@patchysicp.xyz>
Thu, 25 Jan 2024 02:42:22 +0000 (04:42 +0200)
committerEgor <egor@patchysicp.xyz>
Thu, 25 Jan 2024 02:43:37 +0000 (04:43 +0200)
data/.gitignore
src/irc.c

index 63bc720..2a04b68 100644 (file)
@@ -8,3 +8,4 @@ newusers.txt
 help.txt
 motd.txt
 certfp.txt
+nicks.txt
index 6801c3c..2880d7f 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -480,11 +480,21 @@ saslcleanup:
        } else if(strcmp(command, "GHOST") == 0) {
                if (!(client->umode & UMODE_REGISTERED))
                        return 0; // FIXME: error message
-               struct client_data *cl = findClient(client->username);
+               const char *desired_nick = client->username;
+               if (args[0]) {
+                       stringlower(args[0]);
+                       desired_nick = args[0];
+                       if (strcmp(desired_nick, client->username) != 0) {
+                               const char *username = db_read_rhs(desired_nick, getdatafile("nicks.txt"));
+                               if (!username || strcmp(username, client->username) != 0)
+                                       return err_nicknameinuse(client, desired_nick), sendbuf(client), 0;
+                       }
+               }
+               struct client_data *cl = findClient(desired_nick);
                if (!cl)
-                       return 0; // FIXME: error message
+                       return err_nosuchnick(client, desired_nick), sendbuf(client), 0;
                if (client == cl)
-                       return 0; // FIXME: error message
+                       return err_nicknameinuse(client, desired_nick), sendbuf(client), 0;
                killConnection(cl, 0);
        } else if(strcmp(command, "WALLOPS") == 0) {
                if (!is_registered(client))