mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
netwatch-notify: move check in DNS cache to local function
This commit is contained in:
parent
01d2c3ea7e
commit
6f29c640e4
|
@ -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 . \
|
||||
|
|
Loading…
Reference in a new issue