mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-12-06 09:59:28 +00:00
fw-addr-lists: normalize IPv4 addresses
This commit is contained in:
parent
9fa11cb79a
commit
47309e5c03
1 changed files with 9 additions and 2 deletions
|
|
@ -22,10 +22,12 @@
|
|||
:global EitherOr;
|
||||
:global FetchHuge;
|
||||
:global HumanReadableNum;
|
||||
:global IfThenElse;
|
||||
:global LogPrint;
|
||||
:global LogPrintOnce;
|
||||
:global LogPrintVerbose;
|
||||
:global MIN;
|
||||
:global NetMask4;
|
||||
:global ScriptLock;
|
||||
:global WaitFullyConnected;
|
||||
|
||||
|
|
@ -114,8 +116,13 @@
|
|||
:do {
|
||||
:local Branch;
|
||||
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
|
||||
:if ($Address ~ "/32\$") do={
|
||||
:set Address [ :pick $Address 0 ([ :len $Address ] - 3) ];
|
||||
:local Net $Address;
|
||||
:local CIDR 32;
|
||||
:local Slash [ :find $Address "/" ];
|
||||
:if ([ :typeof $Slash ] = "num") do={
|
||||
:set Net [ :toip [ :pick $Address 0 $Slash ] ]
|
||||
:set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
|
||||
:set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ];
|
||||
}
|
||||
:set Branch [ $GetBranch $Address ];
|
||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue