summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-29 22:17:59 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-29 22:17:59 +0100
commit25d3f37161417b7820640ce64bdb7d2433f5e84b (patch)
tree57d7a429ca34c35d5d37c13b8ee0ce76c66db416
parent0bfc35c88e75a7eb47c38f7a31b6cf7f84130ea5 (diff)
Implement BLABOUNCER QUIT command.
-rw-r--r--README1
-rw-r--r--TODO2
-rw-r--r--blabouncer.c19
3 files changed, 20 insertions, 2 deletions
diff --git a/README b/README
index 7528ecf..9bee79b 100644
--- a/README
+++ b/README
@@ -19,6 +19,7 @@ If you don't specify one using "-c /path/to/configuration/file" then the example
Once connected to blabouncer with a client, you can use the following commands:
"BLABOUNCER REPLAY [[[[days:]hours:]minutes:]seconds]" (To replay a given length of time of replay log.)
+"BLABOUNCER QUIT [quit message]" (To quit blabouncer, optionally sending [quit message] to the server.)
Blabouncer commands are all prefixed with BLABOUNCER which you can usually send using "/QUOTE BLABOUNCER".
diff --git a/TODO b/TODO
index 65f042a..e7d8df2 100644
--- a/TODO
+++ b/TODO
@@ -11,8 +11,6 @@ Send a PING to the server before assuming a timeout is definite.
Implement daemon (background) mode.
-Implement BLABOUNCER EXIT command.
-
Implement connect commands (plus maybe a specific NickServ IDENTIFY command).
Include NOTICEs in the replay log.
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;
}