From d23d05f2ea3b3d0e5c11d0780ef87566641296c7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 5 Sep 2024 22:10:11 +0200 Subject: fw-addr-lists: handle JSON format from spamhaus.org Closes: https://github.com/eworm-de/routeros-scripts/issues/79 --- fw-addr-lists.rsc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'fw-addr-lists.rsc') diff --git a/fw-addr-lists.rsc b/fw-addr-lists.rsc index 4930e86..4675e3a 100644 --- a/fw-addr-lists.rsc +++ b/fw-addr-lists.rsc @@ -88,7 +88,12 @@ :while ([ :len $Data ] != 0) do={ :local Line [ :pick $Data 0 [ :find $Data "\n" ] ]; - :local Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); + :local Address; + :if ([ :pick $Line 0 1 ] = "{") do={ + :set Address [ :tostr ([ :deserialize from=json $Line ]->"cidr") ]; + } else={ + :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr")); + } :do { :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={ :set ($IPv4Addresses->$Address) $TimeOut; -- cgit v1.2.3-70-g09d2