From 21a8983aa437a98bb6ac927e00063d0a8291a8da Mon Sep 17 00:00:00 2001 From: cbiselli Date: Tue, 15 Oct 2024 09:31:47 +0200 Subject: [PATCH] limiting location agent version --- www/work/getwork.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/www/work/getwork.php b/www/work/getwork.php index f1962a418a..57f09f2d82 100644 --- a/www/work/getwork.php +++ b/www/work/getwork.php @@ -40,6 +40,11 @@ } } +if (!CheckAgentVersion()) { + header("HTTP/1.1 403 Unauthorized"); + exit(); +} + $block_list = GetSetting('block_pc'); if ($block_list && strlen($block_list) && strlen($pc)) { $block = explode(',', $block_list); @@ -260,6 +265,23 @@ function TestToJSON($testInfo) return $testJson; } +/** + * Used to enforce version limitation for specific locaitons + * + */ +function CheckAgentVersion() +{ + global $locations; + $location = trim($locations[0]); + $locInfo = GetLocationInfo($location); + $agent_version = $_GET['version']; + if (isset($locInfo) && is_array($locInfo) && array_key_exists('version', $locInfo)) { + return $locInfo['version'] === $agent_version; + } + + return true; +} + /** * Get an actual task to complete *