From 2a1d4b2e958de1581e9bda7b07b705b963e394a6 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Mon, 11 Aug 2025 23:02:08 +0100 Subject: Implement update checking using the command "BLABOUNCER UPDATECHECK", or optionally (enabled by default, toggled with configuration option "checkupdates") at startup and successful client authentication. This is implemented using a DNS TXT record check to the domain "version.blabouncer.blatech.net". --- blabouncer.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index b3e239d..443c75c 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1331,6 +1331,13 @@ int main(int argc, char *argv[]) { strncat(conffailmsg, "Error getting 'alertautheddisconnect' from configuration file.\n", sizeof conffailmsg - strlen(conffailmsg) - 1); } + // Is check for updates upon startup and successful client authentication enabled? + settings.checkupdates = getconfint("checkupdates", settings.conffile); + if (errno == ECONFINT) { + conffail = 1; + strncat(conffailmsg, "Error getting 'checkupdates' from configuration file.\n", sizeof conffailmsg - strlen(conffailmsg) - 1); + } + // How many debug logs should we keep? settings.debugkeep = getconfint("debugkeep", settings.conffile); if (errno == ECONFINT) { @@ -1439,6 +1446,21 @@ int main(int argc, char *argv[]) { debugprint(DEBUG_SOME, "Using configuration file '%s'.\n", settings.conffile); + // Check for updates (if enabled in configuration file with checkupdates = "1") + if (settings.checkupdates) { + debugprint(DEBUG_SOME, "Checking for blabouncer updates (checkupdates = \"0\" to disable)...\n"); + char version[MAXDNSTXTLEN]; + version[0] = '\0'; + int ret = checkversion(version); + if (ret == 1) { + debugprint(DEBUG_SOME, "main(): blabouncer appears to be up to date.\n"); + } else if (ret == -1) { + debugprint(DEBUG_SOME, "main(): blabouncer appears to be out of date, latest version is %s.\n", version); + } else { + debugprint(DEBUG_CRIT, "main(): Version check failed!\n"); + } + } + // Unless specified otherwise on the command line, fork to background if (settings.background) { pid_t pid, sid; -- cgit v1.2.3