]> PatchyGit - patchyircd.git/commitdiff
nick!user@host for messages originating from users
authorEgor <egor@patchysicp.xyz>
Tue, 3 May 2022 12:17:34 +0000 (15:17 +0300)
committerEgor <egor@patchysicp.xyz>
Tue, 3 May 2022 12:17:34 +0000 (15:17 +0300)
common.h
irc.c
net.c

index 4aaabae..b00d0d1 100644 (file)
--- a/common.h
+++ b/common.h
@@ -16,6 +16,7 @@ struct client_data {
        char   *key; // case-mapped nick
        char   *username;
        char   *realname;
+       char   *hostname;
        char   buf[2048];
        size_t bufLen;
        size_t bufCap;
diff --git a/irc.c b/irc.c
index 1526ef3..4b4660d 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -107,6 +107,9 @@ int processPacket(struct client_data *client) {
                client->realname = strdup(args[3]);
                if (!client->realname)
                        abort();
+               client->hostname = strdup(hostname);
+               if (!client->hostname)
+                       abort();
                // Send welcome
                if (client->nick && client->username)
                        newUser(client);
@@ -123,7 +126,7 @@ int processPacket(struct client_data *client) {
                                *p = '\0';
                                break;
                        }
-               copy_strf(&databuf, ":%s JOIN :%s\n", client->nick, args[0]);
+               copy_strf(&databuf, ":%s!%s@%s JOIN :%s\n", client->nick, client->username, client->hostname, args[0]);
                // End GitHub Copilot
                send_log(client->FD, databuf.buf, databuf.len, 0);
                sendall_log(client->FD, databuf.buf, databuf.len, 0);
@@ -141,11 +144,11 @@ int processPacket(struct client_data *client) {
                        return 0;
                if (argc < 2) // FIXME: error message
                        return 0;
-               copy_strf(&databuf, ":%s PRIVMSG %s :%s\n", client->nick, args[0], args[1]);
+               copy_strf(&databuf, ":%s!%s@%s PRIVMSG %s :%s\n", client->nick, client->username, client->hostname, args[0], args[1]);
                sendall_log(client->FD, databuf.buf, databuf.len, 0);
        // Start GitHub Copilot - this shit actually be copy pasting my code lmao
        } else if(strcmp(command, "QUIT") == 0) {
-               copy_strf(&databuf, ":%s QUIT :%s\n", client->nick, args[0] ? args[0] : "Client Quit");
+               copy_strf(&databuf, ":%s!%s@%s QUIT :%s\n", client->nick, client->username, client->hostname, args[0] ? args[0] : "Client Quit");
                sendall_log(client->FD, databuf.buf, databuf.len, 0);
                killConnection(client, true);
                return 1;
@@ -316,7 +319,7 @@ void setNick(struct client_data *client, char* nickname) {
 
        // Update nickname
        if(client->nick) {
-               copy_strf(&databuf, ":%s NICK %s\n", client->nick, nickname);
+               copy_strf(&databuf, ":%s!%s@%s NICK %s\n", client->nick, client->username, client->hostname, nickname);
                send_log(client->FD, databuf.buf, databuf.len, 0);
                sendall_log(client->FD, databuf.buf, databuf.len, 0);
                trie_set(&client_map, client->key, NULL, NULL);
diff --git a/net.c b/net.c
index dd239e7..266a452 100644 (file)
--- a/net.c
+++ b/net.c
@@ -51,8 +51,8 @@ void killConnection(struct client_data *cl, bool byChoice) {
        }
 #endif
        // Start GitHub Copilot
-       if(!byChoice) {
-               copy_strf(&databuf, ":%s QUIT :Has left the building (Forced)\n", cl->nick);
+       if(!byChoice && cl->nick && cl->username) {
+               copy_strf(&databuf, ":%s!%s@%s QUIT :Has left the building (Forced)\n", cl->nick, cl->username, cl->hostname);
                sendall_log(cl->FD, databuf.buf, databuf.len, 0);
        }
        // Send error to client informing them that they will be disconnected
@@ -68,6 +68,7 @@ void killConnection(struct client_data *cl, bool byChoice) {
        free(cl->key);
        free(cl->username);
        free(cl->realname);
+       free(cl->hostname);
        free(cl);
 }