mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
fw-addr-lists: rename variable
This commit is contained in:
parent
31966479dc
commit
0125f102b4
1 changed files with 11 additions and 11 deletions
|
@ -38,10 +38,10 @@ $WaitFullyConnected;
|
||||||
:local ListComment ("managed by " . $0);
|
:local ListComment ("managed by " . $0);
|
||||||
|
|
||||||
:foreach FwListName,FwList in=$FwAddrLists do={
|
:foreach FwListName,FwList in=$FwAddrLists do={
|
||||||
:local Addresses ({});
|
|
||||||
:local CntAdd 0;
|
:local CntAdd 0;
|
||||||
:local CntRenew 0;
|
:local CntRenew 0;
|
||||||
:local CntRemove 0;
|
:local CntRemove 0;
|
||||||
|
:local IPv4Addresses ({});
|
||||||
:local Failure false;
|
:local Failure false;
|
||||||
|
|
||||||
:foreach List in=$FwList do={
|
:foreach List in=$FwList do={
|
||||||
|
@ -85,7 +85,7 @@ $WaitFullyConnected;
|
||||||
:local Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
|
:local Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
|
||||||
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$" || \
|
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$" || \
|
||||||
$Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
|
$Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
|
||||||
:set ($Addresses->$Address) $TimeOut;
|
:set ($IPv4Addresses->$Address) $TimeOut;
|
||||||
}
|
}
|
||||||
:set Data [ :pick $Data ([ :len $Line ] + 1) [ :len $Data ] ];
|
:set Data [ :pick $Data ([ :len $Line ] + 1) [ :len $Data ] ];
|
||||||
}
|
}
|
||||||
|
@ -93,28 +93,28 @@ $WaitFullyConnected;
|
||||||
|
|
||||||
:foreach Entry in=[ /ip/firewall/address-list/find where list=$FwListName comment=$ListComment ] do={
|
:foreach Entry in=[ /ip/firewall/address-list/find where list=$FwListName comment=$ListComment ] do={
|
||||||
:local Address [ /ip/firewall/address-list/get $Entry address ];
|
:local Address [ /ip/firewall/address-list/get $Entry address ];
|
||||||
:if ([ :typeof ($Addresses->$Address) ] = "time") do={
|
:if ([ :typeof ($IPv4Addresses->$Address) ] = "time") do={
|
||||||
$LogPrintExit2 debug $0 ("Renewing address for " . ($Addresses->$Address) . ": " . $Address) false;
|
$LogPrintExit2 debug $0 ("Renewing IPv4 address for " . ($IPv4Addresses->$Address) . ": " . $Address) false;
|
||||||
/ip/firewall/address-list/set $Entry timeout=($Addresses->$Address);
|
/ip/firewall/address-list/set $Entry timeout=($IPv4Addresses->$Address);
|
||||||
:set ($Addresses->$Address);
|
:set ($IPv4Addresses->$Address);
|
||||||
:set CntRenew ($CntRenew + 1);
|
:set CntRenew ($CntRenew + 1);
|
||||||
} else={
|
} else={
|
||||||
:if ($Failure = false) do={
|
:if ($Failure = false) do={
|
||||||
$LogPrintExit2 debug $0 ("Removing address: " . $Address) false;
|
$LogPrintExit2 debug $0 ("Removing IPv4 address: " . $Address) false;
|
||||||
/ip/firewall/address-list/remove $Entry;
|
/ip/firewall/address-list/remove $Entry;
|
||||||
:set CntRemove ($CntRemove + 1);
|
:set CntRemove ($CntRemove + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:foreach Address,Timeout in=$Addresses do={
|
:foreach Address,Timeout in=$IPv4Addresses do={
|
||||||
$LogPrintExit2 debug $0 ("Adding address for " . $Timeout . ": " . $Address) false;
|
$LogPrintExit2 debug $0 ("Adding IPv4 address for " . $Timeout . ": " . $Address) false;
|
||||||
:do {
|
:do {
|
||||||
/ip/firewall/address-list/add list=$FwListName comment=$ListComment address=$Address timeout=$Timeout;
|
/ip/firewall/address-list/add list=$FwListName comment=$ListComment address=$Address timeout=$Timeout;
|
||||||
:set ($Addresses->$Address);
|
:set ($IPv4Addresses->$Address);
|
||||||
:set CntAdd ($CntAdd + 1);
|
:set CntAdd ($CntAdd + 1);
|
||||||
} on-error={
|
} on-error={
|
||||||
$LogPrintExit2 warning $0 ("Failed to add address " . $Address . " to list '" . $FwListName . "'.") false;
|
$LogPrintExit2 warning $0 ("Failed to add IPv4 address " . $Address . " to list '" . $FwListName . "'.") false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue