diff options
Diffstat (limited to 'message.c')
-rw-r--r-- | message.c | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -1033,6 +1033,31 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int // Send our own greeting message snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Welcome to blabouncer version %s!", ircdstate->ircnick, VERSION); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + + // Check for updates (if enabled in configuration file with checkupdates = "1") + if (settings->checkupdates) { + debugprint(DEBUG_FULL, "Checking for blabouncer updates on client connection.\n"); + char version[MAXDNSTXTLEN]; + version[0] = '\0'; + int ret = checkversion(version); + if (ret == 1) { + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be up to date.", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } else if (ret == -1) { + + // Next prepare the topic who/when message... + if (!snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be out of date, latest version is %s.", ircdstate->ircnick, version)) { + fprintf(stderr, "processclientmessage() Error while preparing out of date version warning after client connected (version string too long?)!\n"); + debugprint(DEBUG_CRIT, "processclientmessage() Error while preparing out of date version warning after client connected (version string too long?)!\n"); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be out of date, but couldn't print latest version in this NOTICE.", ircdstate->ircnick); + } + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } else { + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Version check failed!", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } + } + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer commands are all prefixed with BLABOUNCER which you can usually send using \"/QUOTE BLABOUNCER\"", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Valid blabouncer commands are:", ircdstate->ircnick); @@ -1051,6 +1076,8 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER VERSION\" (To show the current blabouncer version.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER UPDATECHECK\" (To check for blabouncer version updates.)", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); // Get the channel count so we can iterate over all channels. int channelcount = getchannelcount(channels, ircdstate->maxchannelcount); @@ -1528,6 +1555,31 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :This is blabouncer version %s!", ircdstate->ircnick, VERSION); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); return 1; + // UPDATECHECK received, send current blabouncer version + } else if (strncasecmp(tokens[1], "UPDATECHECK", strlen("UPDATECHECK")) == 0) { + debugprint(DEBUG_SOME, "Client BLABOUNCER UPDATECHECK found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1])); + + char version[MAXDNSTXTLEN]; + version[0] = '\0'; + int ret = checkversion(version); + if (ret == 1) { + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be up to date.", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } else if (ret == -1) { + + // Next prepare the topic who/when message... + if (!snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be out of date, latest version is %s.", ircdstate->ircnick, version)) { + fprintf(stderr, "processclientmessage() Error while preparing out of date version warning after client connected (version string too long?)!\n"); + debugprint(DEBUG_CRIT, "processclientmessage() Error while preparing out of date version warning after client connected (version string too long?)!\n"); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Blabouncer appears to be out of date, but couldn't print latest version in this NOTICE.", ircdstate->ircnick); + } + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } else { + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Version check failed!", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + } + + return 1; // LISTCLIENTS received, send list of connected clients and their authentication status } else if (strncasecmp(tokens[1], "LISTCLIENTS", strlen("LISTCLIENTS")) == 0) { debugprint(DEBUG_SOME, "Client BLABOUNCER LISTCLIENTS found and it is: %s with length %zd!\n", tokens[1], strlen(tokens[1])); @@ -1610,6 +1662,8 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER VERSION\" (To show the current blabouncer version.)", ircdstate->ircnick); sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); + snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :\"BLABOUNCER UPDATECHECK\" (To check for blabouncer version updates.)", ircdstate->ircnick); + sendtoclient(sourcefd, outgoingmsg, clients, settings, 0); return 1; } } |