diff --git a/README.md b/README.md index e5ed9c0..2c703e7 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,13 @@ Set the `QUERY_PORT` environment variable to change the UDP port. If not set, it QUERY_PORT=27015 ``` +This plugin automatically checks for updates using the github API. To disable this feature, set the `SOURCEQUERY_UPDATE_CHECK` +environment variable to `false`. + +```bash +SOURCEQUERY_UPDATE_CHECK=false +``` + ## What it exposes - **A2S_INFO** - Server name, map, player count, max players, game version diff --git a/src/main/java/com/infraly/sourcequery/SourceQueryPlugin.java b/src/main/java/com/infraly/sourcequery/SourceQueryPlugin.java index be322f5..6d7c0b0 100644 --- a/src/main/java/com/infraly/sourcequery/SourceQueryPlugin.java +++ b/src/main/java/com/infraly/sourcequery/SourceQueryPlugin.java @@ -49,7 +49,10 @@ protected void setup() { t.setDaemon(true); return t; }); - scheduler.schedule(this::checkForUpdates, 30, TimeUnit.SECONDS); + + if (this.shouldCheckForUpdates()) { + scheduler.schedule(this::checkForUpdates, 30, TimeUnit.SECONDS); + } } @Override @@ -74,6 +77,14 @@ private int resolveQueryPort() { return Options.getOptionSet().valuesOf(Options.BIND).getFirst().getPort() + 1; } + private boolean shouldCheckForUpdates() { + String env = System.getenv("SOURCEQUERY_UPDATE_CHECK"); + if (env != null) { + return env.equalsIgnoreCase("true") || env.equalsIgnoreCase("1"); + } + return true; + } + private void checkForUpdates() { try { HttpClient client = HttpClient.newBuilder()