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 EitherOr;
|
||||||
:global FetchHuge;
|
:global FetchHuge;
|
||||||
:global HumanReadableNum;
|
:global HumanReadableNum;
|
||||||
|
:global IfThenElse;
|
||||||
:global LogPrint;
|
:global LogPrint;
|
||||||
:global LogPrintOnce;
|
:global LogPrintOnce;
|
||||||
:global LogPrintVerbose;
|
:global LogPrintVerbose;
|
||||||
:global MIN;
|
:global MIN;
|
||||||
|
:global NetMask4;
|
||||||
:global ScriptLock;
|
:global ScriptLock;
|
||||||
:global WaitFullyConnected;
|
:global WaitFullyConnected;
|
||||||
|
|
||||||
|
|
@ -114,8 +116,13 @@
|
||||||
:do {
|
:do {
|
||||||
:local Branch;
|
: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 ~ "^[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={
|
:local Net $Address;
|
||||||
:set Address [ :pick $Address 0 ([ :len $Address ] - 3) ];
|
: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 Branch [ $GetBranch $Address ];
|
||||||
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue