diff options
author | Christian Hesse <mail@eworm.de> | 2024-11-05 17:49:28 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-11-06 22:42:40 +0100 |
commit | 084c246ef0cab329fe981732089277fa8398800b (patch) | |
tree | 0a2b9ed0d30b1d24a69a245177bf6757557c09b3 /fw-addr-lists.rsc | |
parent | 31dfdf7e6243527d77af6b4ae93e753cd45c8cbb (diff) |
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.
Diffstat (limited to 'fw-addr-lists.rsc')
-rw-r--r-- | fw-addr-lists.rsc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 4675e3a..a9513d8 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -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 ] ]; } } |