]> PatchyGit - patchyircd.git/commitdiff
Fixed ping
authorSam Smith <sam@patchysicp.xyz>
Sun, 24 Apr 2022 21:23:50 +0000 (14:23 -0700)
committerSam Smith <sam@patchysicp.xyz>
Sun, 24 Apr 2022 21:23:50 +0000 (14:23 -0700)
irc.c

diff --git a/irc.c b/irc.c
index b09c5b3..cb9db64 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -4,8 +4,16 @@ void processPacket(struct client_data *client) {
        char *packet = client->buf;
        size_t packetLen = client->bufLen;
        if(strncmp(packet, "PING", 4) == 0) {
+               char data[1024];
                packet[1] = 'O';
-               send_log(client->FD, packet, packetLen, 0);
+               // Mem unsafe time
+               strcpy(packet+5+strlen("irc.patchysicp.xyz "), packet+4);
+               strcpy(packet+5, "irc.patchysicp.xyz ");
+               packet[5+strlen("irc.patchysicp.xyz ")] = ':';
+               strcpy(data, ":irc.patchysicp.xyz ");
+               strcpy(data+strlen(":irc.patchysicp.xyz "), packet);
+               data[strlen(":irc.patchysicp.xyz")] = ' ';
+               send_log(client->FD, data, strlen(data), 0);
        } else if(strncmp(packet, "NICK ", 5) == 0) {
                // User now registered
                setNick(client, packet+5, 32);