diff options
author | Christian Hesse <mail@eworm.de> | 2024-09-05 22:10:11 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-09-11 10:48:45 +0200 |
commit | d23d05f2ea3b3d0e5c11d0780ef87566641296c7 (patch) | |
tree | 41c47c60b86eb4079b0807de787e37b61449f7dd /fw-addr-lists.rsc | |
parent | 09dcd51feb0d17e7c0715aa10786df169936760a (diff) |
fw-addr-lists: handle JSON format from spamhaus.org
Closes: https://github.com/eworm-de/routeros-scripts/issues/79
Diffstat (limited to 'fw-addr-lists.rsc')
-rw-r--r-- | fw-addr-lists.rsc | 7 |
1 files changed, 6 insertions, 1 deletions
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; |