I'm struggling with getting to run script that I found to import IP addresses from file and adding them to my address list.
Idea is to fetch file with all official country IP addresses from Web page (file name is "local.net") and add them to list.
Fetching script is working fine, bet when I run the script to add IP to list I get only first number added to my address list. Also, is there "4096 byte read/write limit" workaround?
Maybe there is some scripting guru that can help me?
Script that I am using is:
:if ( [/file get [/file find name=local.net] size] > 0 ) do={
/ip firewall address-list remove [/ip firewall address-list find list=Test]
:local content [/file get [/file find name=local.net] contents] ;
:local contentLen [ :len $content ] ;
:put ( "=>" . $content . "<=" )
:local lineEnd 0
:local line ""
:local lastEnd [ :tonum 0 ]
:do {
:set line [ :pick $content $lastEnd [ :find $content "\r\n" $lastEnd ] ]
:set lineEnd [:find $content "\n" $lastEnd ] ;
:put "lineEnd=$lineEnd< - lastEnd=$lastEnd - line=$line<"
:if ( [ :len $content ] = 0 ) do={
:put "UNIX"
:set line [ :pick $content $lastEnd [ :find $content "\r\n" $lastEnd ] ]
:set lineEnd [:find $content "\n" $lastEnd ] ;
}
:set lastEnd ( $lineEnd + 1 ) ;
:if ( [:pick $line 0 1] != "\n" ) do={
:put ">$line<"
:if ( [:len $line ] > 0 ) do={ /ip firewall address-list add list=Test address=$line }
}
} while ($lineEnd < $contentLen)
}