1
0
mirror of https://github.com/eworm-de/routeros-scripts.git synced 2024-05-11 05:55:19 +00:00

dhcp-to-dns: check for existence of address

Chances are that $LeaseVal is an array with just an id - no idea why this
happens. So do not check for array but existence of address.
This commit is contained in:
Christian Hesse
2021-08-26 11:08:55 +02:00
parent 772e66b622
commit d556e97a46

View File

@@ -58,7 +58,7 @@ $ScriptLock $0 false 10;
$LogPrintExit2 debug $0 ("A lease just vanished, ignoring.") false; $LogPrintExit2 debug $0 ("A lease just vanished, ignoring.") false;
} }
:if ([ :typeof $LeaseVal ] = "array") do={ :if ([ :len ($LeaseVal->"address") ] > 0) do={
:local Comment ($CommentPrefix . $LeaseVal->"mac-address"); :local Comment ($CommentPrefix . $LeaseVal->"mac-address");
:local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \ :local HostName [ $IfThenElse ([ :len ($LeaseVal->"host-name") ] = 0) \
[ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \ [ $CharacterReplace ($LeaseVal->"mac-address") ":" "-" ] \
@@ -91,5 +91,7 @@ $ScriptLock $0 false 10;
$LogPrintExit2 info $0 ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false; $LogPrintExit2 info $0 ("Adding new DNS entry for " . $Fqdn . ", address is " . $LeaseVal->"address" . ".") false;
/ ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore; / ip dns static add name=$Fqdn address=($LeaseVal->"address") ttl=$Ttl comment=$Comment place-before=$PlaceBefore;
} }
} else={
$LogPrintExit2 debug $0 ("No address available... Ignoring.") false;
} }
} }