diff options
Diffstat (limited to 'message.c')
-rw-r--r-- | message.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -873,6 +873,8 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int 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.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER REHASH\" (To reload settings from the configuration file, see README for which settings can be reloaded.)", ircdstate->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.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); @@ -1253,7 +1255,31 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int } else { cleanexit(server_ssl, clients, sourcefd, ircdstate, settings, ""); } + // REHASH received, re-read the configuration file and let rehash() to the appropriate things + } else if (strncasecmp(tokens[1], "REHASH", strlen("REHASH")) == 0) { + debugprint(DEBUG_SOME, "Client BLABOUNCER REHASH found and it is: %s with length %zd! Attempting rehash...\n", tokens[1], strlen(tokens[1])); + + // TODO - This code is duplicated between here and SIGHUP handling + + char failuremsg[MAXDATASIZE]; + failuremsg[0] = '\0'; + // Try to rehash... + if (!rehash(settings, failuremsg)) { + // ...or log and tell client if it failed + debugprint(DEBUG_CRIT, "REHASH failed: %s.\n", failuremsg); + if (!snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :REHASH failed: %s.", ircdstate->ircnick, failuremsg)) { + debugprint(DEBUG_CRIT, "Error while preparing REHASH failure message response!\n"); + outgoingmsg[0] = '\0'; + } + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } else { + // ...or tell all clients it worked + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :REHASH complete!", ircdstate->ircnick); + sendtoallclients(clients, outgoingmsg, 0, settings); + } + + return 1; // Unrecognised BLABOUNCER command received, send some help instructions } else { debugprint(DEBUG_SOME, "Client BLABOUNCER unrecognised command found and it is: %s with length %zd! Sending a help message.\n", tokens[1], strlen(tokens[1])); @@ -1261,6 +1287,8 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int 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.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER REHASH\" (To reload settings from the configuration file, see README for which settings can be reloaded.)", ircdstate->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.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); return 1; |