Compare commits

..

16 commits

Author SHA1 Message Date
Christian Hesse
a853e172fa check-certificates: better error handling and reporting for downloads 2026-01-22 14:26:21 +01:00
Christian Hesse
3394f0a140 global-functions: $NetMask6: use shift operator...
... and drop the workaround. This requires RouterOS 7.22beta3.
2026-01-22 10:59:15 +01:00
Christian Hesse
d3fb2ab982 Merge branch 'break-in-loop' into next 2026-01-22 10:59:15 +01:00
Christian Hesse
7bf523275a Merge branch 'continue-in-loop' into next 2026-01-22 10:59:15 +01:00
Christian Hesse
b1e4e89585 telegram-chat: fix indention 2026-01-22 10:59:15 +01:00
Christian Hesse
9f005a16a1 telegram-chat: use :continue in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
3b73af9559 telegram-chat: use :break in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
99cf486b8e netwatch-dns: fix indention 2026-01-22 10:59:15 +01:00
Christian Hesse
2e2f3c4b1a netwatch-dns: use :continue in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
db880aea76 netwatch-dns: fix indention 2026-01-22 10:59:15 +01:00
Christian Hesse
fe5f28ea6c netwatch-dns: use :continue in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
2a321c430a global-functions: $ScriptInstallUpdate: fix indention 2026-01-22 10:59:15 +01:00
Christian Hesse
2e71b055db global-functions: $ScriptInstallUpdate: use :continue in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
b3c2088ee9 fw-addr-lists: fix indention 2026-01-22 10:59:15 +01:00
Christian Hesse
c13a22e15c fw-addr-lists: use :continue in loop 2026-01-22 10:59:15 +01:00
Christian Hesse
9312f677fe check-certificates: use :continue in loop 2026-01-22 10:59:15 +01:00
3 changed files with 34 additions and 27 deletions

View file

@ -54,9 +54,17 @@
"' (file '" . $CertFileName . "')...");
:do {
/tool/fetch check-certificate=yes-without-crl http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \
($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value;
$WaitForFile $CertFileName;
:onerror Err {
/tool/fetch check-certificate=yes-without-crl \
http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) \
($CertRenewUrl . $CertFileName) dst-path=$CertFileName as-value;
} do={
:if ($Err != "Fetch failed with status 404") do={
$LogPrint warning $0 ("Failed fetching certificate: " . $Err);
}
:error false;
}
$WaitForFile $CertFileName;
:local DecryptionFailed true;
:foreach I,PassPhrase in=$CertRenewPass do={

View file

@ -121,22 +121,22 @@
} do={
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
" failed: " . $Err);
:continue;
}
:if ($Data != false) do={
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] = "num") do={
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
:if ([ /certificate/settings/get crl-use ] = true) do={
$LogPrintOnce warning $ScriptName ("Configured to use CRL, that can cause severe issue!");
}
/ip/dns/cache/flush;
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
:exit;
} else={
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
:if ([ :typeof [ :find $Data "doh-check-OK" ] ] != "num") do={
$LogPrint warning $ScriptName ("Received unexpected response from DoH server: " . \
($DohServer->"doh-url"));
}
:continue;
}
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
:if ([ /certificate/settings/get crl-use ] = true) do={
$LogPrintOnce warning $ScriptName ("Configured to use CRL, that can cause severe issue!");
}
/ip/dns/cache/flush;
$LogPrint info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url"));
:exit;
}
} do={
:global ExitOnError; $ExitOnError [ :jobname ] $Err;

View file

@ -68,18 +68,17 @@
:local Data false;
:for I from=1 to=4 do={
:if ($Data = false) do={
:onerror Err {
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
$TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
:set TelegramRandomDelay [ $MAX 0 ($TelegramRandomDelay - 1) ];
} do={
:if ($I < 4) do={
$LogPrint debug $ScriptName ("Fetch failed, " . $I . ". try: " . $Err);
:set TelegramRandomDelay [ $MIN 15 ($TelegramRandomDelay + 5) ];
:delay (($I * $I) . "s");
}
:onerror Err {
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
("https://api.telegram.org/bot" . $TelegramTokenId . "/getUpdates?offset=" . \
$TelegramChatOffset->0 . "&allowed_updates=%5B%22message%22%5D") as-value ]->"data");
:set TelegramRandomDelay [ $MAX 0 ($TelegramRandomDelay - 1) ];
:break;
} do={
:if ($I < 4) do={
$LogPrint debug $ScriptName ("Fetch failed, " . $I . ". try: " . $Err);
:set TelegramRandomDelay [ $MIN 15 ($TelegramRandomDelay + 5) ];
:delay (($I * $I) . "s");
}
}
}