aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-dns.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'netwatch-dns.rsc')
-rw-r--r--netwatch-dns.rsc32
1 files changed, 17 insertions, 15 deletions
diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc
index 467d636..9e2f9bc 100644
--- a/netwatch-dns.rsc
+++ b/netwatch-dns.rsc
@@ -9,11 +9,11 @@
# monitor and manage dns/doh with netwatch
# https://rsc.eworm.de/doc/netwatch-dns.md
-:global GlobalFunctionsReady;
-:while ($GlobalFunctionsReady != true) do={ :delay 500ms; }
-
:local ExitOK false;
-:do {
+:onerror Err {
+ :global GlobalConfigReady; :global GlobalFunctionsReady;
+ :retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
+ do={ :error ("Global config and/or functions not ready."); }; } delay=500ms max=50;
:local ScriptName [ :jobname ];
:global CertificateAvailable;
@@ -118,15 +118,17 @@
}
:local Data false;
- :do {
- :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
- http-header-field=({ "accept: application/dns-message" }) \
- url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
- "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \
- "\00\10" . "\00\01") ]) as-value ]->"data");
- } on-error={
- $LogPrint warning $ScriptName ("Request to DoH server failed (network or certificate issue): " . \
- ($DohServer->"doh-url"));
+ :onerror Err {
+ :retry {
+ :set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
+ http-header-field=({ "accept: application/dns-message" }) \
+ url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
+ "\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm\02de\00" . \
+ "\00\10" . "\00\01") ]) as-value ]->"data");
+ } delay=1s max=3;
+ } do={
+ $LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \
+ " failed: " . $Err);
}
:if ($Data != false) do={
@@ -145,6 +147,6 @@
}
}
}
-} on-error={
- :global ExitError; $ExitError $ExitOK [ :jobname ];
+} do={
+ :global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
}