diff options
author | Luke Bratch <luke@bratch.co.uk> | 2025-08-11 23:02:08 +0100 |
---|---|---|
committer | Luke Bratch <luke@bratch.co.uk> | 2025-08-11 23:02:08 +0100 |
commit | 2a1d4b2e958de1581e9bda7b07b705b963e394a6 (patch) | |
tree | db66b6cd7f3441a244469c57b35dcab65b3f5353 /blabouncer.c | |
parent | 0e7f232b3d5ecb484d9d91bdd7e4b6d4e7791585 (diff) |
Implement update checking using the command "BLABOUNCER UPDATECHECK", or optionally (enabled by default, toggled with configuration option "checkupdates") at startup and successful client authentication.HEADmaster
This is implemented using a DNS TXT record check to the domain "version.blabouncer.blatech.net".
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 22 |
1 files changed, 22 insertions, 0 deletions
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; |