aboutsummaryrefslogtreecommitdiffstats
path: root/netwatch-notify.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-01 12:09:29 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-01 12:30:18 +0100
commit50a69149072be4f66cbd05362fef9ec68f293323 (patch)
treebba311b18ba0db5eb54b5f60ad2136c1c81bbc7c /netwatch-notify.rsc
parent20d1ad17d75497250c0ec155b354b9180457ad44 (diff)
netwatch-notify: (mis-)use firewall address-list for lookup...
... and drop the racy code querying dns cache. 😁
Diffstat (limited to 'netwatch-notify.rsc')
-rw-r--r--netwatch-notify.rsc16
1 files changed, 5 insertions, 11 deletions
diff --git a/netwatch-notify.rsc b/netwatch-notify.rsc
index cd4fc0d..6501ea9 100644
--- a/netwatch-notify.rsc
+++ b/netwatch-notify.rsc
@@ -56,21 +56,15 @@
:local Name [ :tostr $1 ];
:local Expected [ :tostr $2 ];
- :delay 100ms;
+ :global GetRandom20CharAlNum;
- :if ([ :len [ /ip/dns/cache/find where name=$Name data=$Expected ] ] > 0) do={
+ :local FwAddrList ($0 . "-" . [ $GetRandom20CharAlNum ]);
+ /ip/firewall/address-list/add address=$Name list=$FwAddrList dynamic=yes timeout=1s;
+ :delay 20ms;
+ :if ([ :len [ /ip/firewall/address-list/find where list=$FwAddrList address=$Expected ] ] > 0) do={
:return true;
}
- :local Cname [ /ip/dns/cache/find where name=$Name type="CNAME" ];
- :if ([ :len $Cname ] > 0) do={
- :set Cname [ /ip/dns/cache/get $Cname data ];
- :set Cname [ :pick $Cname 0 ([ :len $Cname ] - 1) ];
- :if ([ :len [ /ip/dns/cache/find where name=$Cname data=$Expected ] ] > 0) do={
- :return true;
- }
- }
-
:return false;
}