aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-notify.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-02-28 22:19:26 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-02-28 23:01:43 +0100
commit6f29c640e4e63b6a5e0d986b63dafa54dc2cc3fa (patch)
treecb3a52291f689e501529a311fd4b5fed32af2fc9 /netwatch-notify.rsc
parent01d2c3ea7e3b00a3020705120d896fd6689fab1a (diff)
netwatch-notify: move check in DNS cache to local function
Diffstat (limited to 'netwatch-notify.rsc')
-rw-r--r--netwatch-notify.rsc16
1 files changed, 14 insertions, 2 deletions
diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc
index 5c6ae40..1b6a005 100644
--- a/netwatch-notify.rsc
+++ b/netwatch-notify.rsc
@@ -52,6 +52,19 @@
:return ("Ran hook:\n" . $Hook);
}
+:local ResolveExpected do={
+ :local Name [ :tostr $1 ];
+ :local Expected [ :tostr $2 ];
+
+ :delay 100ms;
+
+ :if ([ :len [ /ip/dns/cache/find where name=$Name data=$Expected ] ] > 0) do={
+ :return true;
+ }
+
+ :return false;
+}
+
$ScriptLock $0;
:local ScriptFromTerminalCached [ $ScriptFromTerminal $0 ];
@@ -80,8 +93,7 @@ $ScriptLock $0;
:do {
:local Resolve [ :resolve ($HostInfo->"resolve") ];
:if ($Resolve != $HostVal->"host") do={
- :delay 100ms;
- :if ([ :len [ /ip/dns/cache/find where name=($HostInfo->"resolve") data=[ :tostr ($HostVal->"host") ] ] ] = 0) do={
+ :if ([ $ResolveExpected ($HostInfo->"resolve") ($HostVal->"host") ] = false) do={
$LogPrintExit2 info $0 ("Name '" . $HostInfo->"resolve" . [ $IfThenElse \
($HostInfo->"resolve" != $HostInfo->"name") ("' for " . $Type . " '" . \
$HostInfo->"name") "" ] . "' resolves to different address " . $Resolve . \