summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/blabouncer.c b/blabouncer.c
index e0c9b21..48bdbd1 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -1617,6 +1617,8 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER REPLAY [[[[days:]hours:]minutes:]seconds]\" (To replay a given length of time of replay log.)", ircdstrings->ircnick);
sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER QUIT [quit message]\" (To quit blabouncer, optionally sending [quit message] to the server.)", ircdstrings->ircnick);
+ sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
// Get the channel count so we can enumerate over all channels.
// Storing separately so we can skip over blank channels.
@@ -1977,6 +1979,21 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
free(timestrcopyPtr);
free(strcopyPtr);
return 1;
+ // QUIT received, send QUIT message to server and exit cleanly
+ } else if (strncasecmp(tokens[1], "QUIT", strlen("QUIT")) == 0) {
+ debugprint("Client QUIT found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1]));
+ // Combine "QUIT :" with any optional quit message the user provided
+ char quitmsg[MAXDATASIZE];
+ if (counter > 2) {
+ // Any optional quit message comes 16 characters after the start of the string ("BLABOUNCER QUIT " is 16 characters)
+ snprintf(quitmsg, MAXDATASIZE, "QUIT :%s", str + 16);
+ } else {
+ snprintf(quitmsg, MAXDATASIZE, "QUIT");
+ }
+ sendtoserver(server_ssl, quitmsg, strlen(quitmsg), sourcefd, clients, settings);
+ debugprint("Exiting on client request.\n");
+ free(strcopyPtr);
+ exit(0);
// Unrecognised BLABOUNCER command received, send some help instructions
} else {
debugprint("Client BLABOUNCER unrecognised command found and it is: %s with length %zd! Sending a help message.\n", tokens[1], strlen(tokens[1]));
@@ -1984,6 +2001,8 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER REPLAY [[[[days:]hours:]minutes:]seconds]\" (To replay a given length of time of replay log.)", ircdstrings->ircnick);
sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER QUIT [quit message]\" (To quit blabouncer, optionally sending [quit message] to the server.)", ircdstrings->ircnick);
+ sendtoclient(sourcefd, outgoingmsg, clients, settings, 0);
free(strcopyPtr);
return 1;
}