From 5d52ed923b122a4e6998ae9a3501f41ff4c06bc3 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 9 Aug 2025 11:34:01 +0100 Subject: Correctly send non-client QUITs and add QUIT message to STDIN quit. --- blabouncer.c | 2 +- functions.c | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/blabouncer.c b/blabouncer.c index 2e569a1..b3e239d 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -847,7 +847,7 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) { printf("STDIN command starting: quit\n"); debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command starting: quit\n"); - cleanexit(server_ssl, clients, 0, &ircdstate, settings, ""); + cleanexit(server_ssl, clients, 0, &ircdstate, settings, "STDIN quit"); debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command complete: quit\n"); printf("STDIN command complete: quit\n"); diff --git a/functions.c b/functions.c index 6eddc35..8ef2b21 100644 --- a/functions.c +++ b/functions.c @@ -1074,15 +1074,13 @@ void tryautonick(struct ircdstate *ircdstate) { void cleanexit(SSL *server_ssl, struct client *clients, int sourcefd, struct ircdstate *ircdstate, struct settings *settings, char *quitmsg) { char outgoingmsg[MAXDATASIZE]; - // Index of client fd in clients array for use later - int clientindex = arrindex(clients, sourcefd); - if (clientindex < 0) { - debugprint(DEBUG_CRIT, "cleanexit(): error: arrindex() returned '%d', exiting!\n", clientindex); - exit(1); - } - // Tell clients and debug log if (sourcefd) { + int clientindex = arrindex(clients, sourcefd); + if (clientindex < 0) { + debugprint(DEBUG_CRIT, "cleanexit(): error: arrindex() returned '%d', exiting!\n", clientindex); + exit(1); + } snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Exiting on request from client %s, message '%s'.", ircdstate->ircnick, clients[clientindex].remoteip, quitmsg); debugprint(DEBUG_CRIT, "Exiting on request from client %s with fd '%d', message '%s'.\n", clients[clientindex].remoteip, sourcefd, quitmsg); } else { -- cgit v1.2.3