aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-dns.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-06 23:53:50 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 15:27:15 +0100
commit6fd39bd3c5d7c3fe5dca9e92275f60e0b3217f03 (patch)
tree7ced2fbdb536447b537a967e945600ba6dd78c8a /netwatch-dns.rsc
parentb86d6314868596dacdf422db80ef0ff27c61c644 (diff)
parentf0856c264e07804a229668268a457f2154cb373a (diff)
Merge branch 'do-with-on-error' into nextrouteros-7.15beta4-2
Diffstat (limited to 'netwatch-dns.rsc')
-rw-r--r--netwatch-dns.rsc16
1 files changed, 7 insertions, 9 deletions
diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc
index 2468d35..76f2685 100644
--- a/netwatch-dns.rsc
+++ b/netwatch-dns.rsc
@@ -11,8 +11,8 @@
:global GlobalFunctionsReady;
:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-:local Main do={
- :local ScriptName [ :tostr $1 ];
+:do {
+ :local ScriptName [ :jobname ];
:global CertificateAvailable;
:global EitherOr;
@@ -21,13 +21,13 @@
:global ScriptLock;
:if ([ $ScriptLock $ScriptName ] = false) do={
- :return false;
+ :error false;
}
:local SettleTime (5m30s - [ /system/resource/get uptime ]);
:if ($SettleTime > 0s) do={
$LogPrintExit2 info $ScriptName ("System just booted, giving netwatch " . $SettleTime . " to settle.") false;
- :return true;
+ :error true;
}
:local DnsServers ({});
@@ -84,7 +84,7 @@
:if ($DohCurrent = $HostInfo->"doh-url") do={
$LogPrintExit2 debug $ScriptName ("Current DoH server is still up: " . $DohCurrent) false;
- :return true;
+ :error true;
}
:set ($DohServers->[ :len $DohServers ]) $HostInfo;
@@ -121,13 +121,11 @@
/ip/dns/set use-doh-server=($DohServer->"doh-url") verify-doh-cert=yes;
/ip/dns/cache/flush;
$LogPrintExit2 info $ScriptName ("Setting DoH server: " . ($DohServer->"doh-url")) false;
- :return true;
+ :error true;
} else={
$LogPrintExit2 warning $ScriptName ("Received unexpected response from DoH server: " . \
($DohServer->"doh-url")) false;
}
}
}
-}
-
-$Main [ :jobname ];
+} on-error={ }