fw-addr-lists: do not use IPv6 net addresses smaller /64

This should reduce the number of addresses in list by aggregating them,
and also fix addresses with host part set (like 2001:470:1:fb5::2a0/64,
which should be 2001:470:1:fb5::/64 really).

The latter caused new warnings with RouterOS 7.21beta2.
This commit is contained in:
Christian Hesse 2025-10-08 16:02:20 +02:00
parent 5ffa85f8bf
commit 9ceed0926a

View file

@ -25,6 +25,7 @@
:global LogPrint;
:global LogPrintOnce;
:global LogPrintVerbose;
:global MIN;
:global ScriptLock;
:global WaitFullyConnected;
@ -120,9 +121,14 @@
:error true;
}
:if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
:if ([ :typeof [ :find $Address "/" ] ] = "nil") do={
:set Address ($Address . "/128");
:local Net $Address;
:local Cidr 64;
:local Slash [ :find $Address "/" ];
:if ([ :typeof $Slash ] = "num") do={
:set Net [ :toip6 [ :pick $Address 0 $Slash ] ]
:set Cidr [ $MIN [ :pick $Address ($Slash + 1) [ :len $Address ] ] 64 ];
}
:set Address (([ :toip6 $Net ] & ffff:ffff:ffff:ffff::) . "/" . $Cidr);
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
:error true;
}