aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-03-10 09:46:16 +0100
committerGravatar Christian Hesse <mail@eworm.de>2023-03-10 09:46:16 +0100
commit56ae457d777620afce8d92ac61b1701eb3ed9922 (patch)
tree3b6c9d98a855234c7aa2ce174a1ee11bb4c665e7 /global-functions.rsc
parent7912091f63ecc56e769d354973fa6fad6d793048 (diff)
global-functions: $ScriptInstallUpdate: add proper version in user agent
This allows me to identify what RouterOS versions are run on devices fetching my scripts, which may helps to decide what incompatible changes to push.
Diffstat (limited to 'global-functions.rsc')
-rw-r--r--global-functions.rsc7
1 files changed, 5 insertions, 2 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index 642b800..6e3f00a 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -753,6 +753,7 @@
:local ExpectedConfigVersionBefore $ExpectedConfigVersion;
:local ReloadGlobalFunctions false;
:local ReloadGlobalConfig false;
+ :local UserAgent ("User-Agent: Mikrotik/" . [ /system/resource/get version ] . " Fetch");
:foreach Script in=[ /system/script/find where source~"^#!rsc by RouterOS\n" ] do={
:local ScriptVal [ /system/script/get $Script ];
@@ -782,7 +783,8 @@
:local Url ($BaseUrl . $ScriptVal->"name" . ".rsc" . $UrlSuffix);
$LogPrintExit2 debug $0 ("Fetching script '" . $ScriptVal->"name" . "' from url: " . $Url) false;
- :local Result [ /tool/fetch check-certificate=yes-without-crl $Url output=user as-value ];
+ :local Result [ /tool/fetch check-certificate=yes-without-crl http-header-field=$UserAgent \
+ $Url output=user as-value ];
:if ($Result->"status" = "finished") do={
:set SourceNew ($Result->"data");
}
@@ -865,7 +867,8 @@
:do {
:local Url ($ScriptUpdatesBaseUrl . "news-and-changes.rsc" . $ScriptUpdatesUrlSuffix);
$LogPrintExit2 debug $0 ("Fetching news, changes and migration: " . $Url) false;
- :local Result [ /tool/fetch check-certificate=yes-without-crl $Url output=user as-value ];
+ :local Result [ /tool/fetch check-certificate=yes-without-crl http-header-field=$UserAgent \
+ $Url output=user as-value ];
:if ($Result->"status" = "finished") do={
:set ChangeLogCode ($Result->"data");
}