HELP with error in script to import the IPv4 full bogons list from www.team-cymru.org

search tag # rextended convert to ip prefix


Reordered and corrected some aspects…


/ip firewall address-list
{
:log info "Remove old bogon list"
remove [find where list="bogons"]

:log info "Fetching bogon list"
:local content ([/tool fetch url="https://www.team-cymru.org/Services/Bogons/fullbogons-ipv4.txt" mode=https output=user as-value]->"data")

:local contentLen [:len $content]
:local lineEnd -1
:local line ""
:local lastEnd -1

:log info "Adding bogons from memory"
:do { :set lineEnd [:find $content "\n" $lastEnd]
      :set line    [:pick $content $lastEnd $lineEnd]
      :set lastEnd ($lineEnd + 1)

      :if ([:typeof [:toip $line]] = "ip") do={
          add list="bogons" timeout=1w address=$line
      } else={
          :do {
              :local xparse ([[:parse ":return $line"]])
              :if ([:typeof $xparse] = "ip-prefix") do={
                  add list="bogons" timeout=1w address=$line
              }
          } on-error={}
      }

} while=($lineEnd < ($contentLen - 1))

:log info "Done."
}

eh eh eh eh… :))

add only if is valid ip-prefix like 6.6.6.0/24 or if a single IP like 6.6.6.1 or for some reason on the file are wited 6.6.6.2/32