diff options
author | Christian Hesse <mail@eworm.de> | 2023-08-18 09:29:22 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2023-08-18 15:23:20 +0200 |
commit | 047c74a4b3feb40528c1fc72b371f3599dab4c2b (patch) | |
tree | 99181cbaa3bc633e4aba1fb9406868d1129f7d14 /global-functions.rsc | |
parent | 53a80c81b18a01dadaef967fd52e2fc2474714fa (diff) |
global-functions: prepare user-agent for fetch in global variable
Diffstat (limited to 'global-functions.rsc')
-rw-r--r-- | global-functions.rsc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/global-functions.rsc b/global-functions.rsc index b9b20ee..8a9b384 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -16,6 +16,7 @@ # global variables not to be changed by user :global GlobalFunctionsReady false; +:global FetchUserAgent ("User-Agent: Mikrotik/" . [ /system/resource/get version ] . " Fetch"); :global Identity [ /system/identity/get name ]; # global functions @@ -108,6 +109,7 @@ :set CertificateDownload do={ :local CommonName [ :tostr $1 ]; + :global FetchUserAgent; :global ScriptUpdatesBaseUrl; :global ScriptUpdatesUrlSuffix; @@ -116,14 +118,12 @@ :global UrlEncode; :global WaitForFile; - :local UserAgent ("User-Agent: Mikrotik/" . [ /system/resource/get version ] . " Fetch"); - $LogPrintExit2 info $0 ("Downloading and importing certificate with " . \ "CommonName \"" . $CommonName . "\".") false; :do { :local LocalFileName ($CommonName . ".pem"); :local UrlFileName ([ $UrlEncode $CommonName ] . ".pem"); - /tool/fetch check-certificate=yes-without-crl http-header-field=$UserAgent \ + /tool/fetch check-certificate=yes-without-crl http-header-field=$FetchUserAgent \ ($ScriptUpdatesBaseUrl . "certs/" . $UrlFileName . $ScriptUpdatesUrlSuffix) \ dst-path=$LocalFileName as-value; $WaitForFile $LocalFileName; @@ -769,6 +769,7 @@ :local NewComment [ :tostr $2 ]; :global ExpectedConfigVersion; + :global FetchUserAgent; :global Identity; :global IDonate; :global NoNewsAndChangesNotification; @@ -806,7 +807,6 @@ :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\r?\n" ] do={ :local ScriptVal [ /system/script/get $Script ]; @@ -836,7 +836,7 @@ :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 http-header-field=$UserAgent \ + :local Result [ /tool/fetch check-certificate=yes-without-crl http-header-field=$FetchUserAgent \ $Url output=user as-value ]; :if ($Result->"status" = "finished") do={ :set SourceNew ($Result->"data"); @@ -920,7 +920,7 @@ :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 http-header-field=$UserAgent \ + :local Result [ /tool/fetch check-certificate=yes-without-crl http-header-field=$FetchUserAgent \ $Url output=user as-value ]; :if ($Result->"status" = "finished") do={ :set ChangeLogCode ($Result->"data"); |