mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-01 08:44:32 +02:00
fw-addr-lists: simplify looping lines
With `:deserialize` the **record** separator is always a new line. The property `delimiter=` is a **field** reparator, so you can parse a lines into an array. We do not want (or need) that, so use new line as field separator. This will result in an array with just one element, and we use that. Also convert the data to line feed explicitly, just to be sure.
This commit is contained in:
parent
31dfdf7e62
commit
084c246ef0
1 changed files with 3 additions and 4 deletions
|
@ -65,7 +65,7 @@
|
|||
|
||||
:for I from=1 to=5 do={
|
||||
:if ($Data = false) do={
|
||||
:set Data [ $FetchHuge $ScriptName ($List->"url") $CheckCertificate ];
|
||||
:set Data [ :tolf [ $FetchHuge $ScriptName ($List->"url") $CheckCertificate ] ];
|
||||
:if ($Data = false) do={
|
||||
:if ($I < 5) do={
|
||||
$LogPrint debug $ScriptName ("Failed downloading for list '" . $FwListName . \
|
||||
|
@ -86,8 +86,8 @@
|
|||
"B for list '" . $FwListName . "' from: " . $List->"url");
|
||||
}
|
||||
|
||||
:while ([ :len $Data ] != 0) do={
|
||||
:local Line [ :pick $Data 0 [ :find $Data "\n" ] ];
|
||||
:foreach Line in=[ :deserialize $Data delimiter="\n" from=dsv options=dsv.plain ] do={
|
||||
:set Line ($Line->0);
|
||||
:local Address;
|
||||
:if ([ :pick $Line 0 1 ] = "{") do={
|
||||
:set Address [ :tostr ([ :deserialize from=json $Line ]->"cidr") ];
|
||||
|
@ -109,7 +109,6 @@
|
|||
:error true;
|
||||
}
|
||||
} on-error={ }
|
||||
:set Data [ :pick $Data ([ :len $Line ] + 1) [ :len $Data ] ];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue