coming from this topic:
viewtopic.php?p=1051864
I found a very useful script for creating variables.
I'm trying to import a file.txt of 8 MB, only it cuts the list to more or less 3 MB.
Was I wrong or is it not possible?
Thank you.
my script is:
:global thefile ""
{
:local url http://public-dns.info/nameservers-all.txt ;
:local filesize ([/tool fetch url=$url as-value output=none]->"downloaded")
:local maxsize 64512 ; # is the maximum supported readable size of a block from a file
:local start 0
:local end ($maxsize - 1)
:local partnumber ($filesize / ($maxsize / 1024))
:local reminder ($filesize % ($maxsize / 1024))
:if ($reminder > 0) do={ :set partnumber ($partnumber + 1) }
:for x from=1 to=$partnumber step=1 do={
:set thefile ($thefile . ([/tool fetch url=$url http-header-field="Range: bytes=$start-$end" as-value output=user]->"data"))
:set start ($start + $maxsize)
:set end ($end + $maxsize)
}
}
#:log info "debug_thefile=$thefile"
#/file remove [find where name="check.txt"];
#:execute ":put \$thefile" file=check.txt;
:global content value=$thefile;
:local contentLen value=[:len $content];
:local lineEnd value=0;
:local line value="";
:local lastEnd value=0;
:local addressListName;
:set addressListName "DNS-DOH";
:if ($thefile != null) do={
:log info "There are some New DNS"
/ip firewall address-list remove [/ip firewall address-list find list=$addressListName]
:do {
:set lineEnd [:find $content "\n" $lastEnd ] ;
:set line [:pick $content $lastEnd $lineEnd] ;
:set lastEnd ( $lineEnd + 1 ) ;
:local entry [:pick $line 0 $lineEnd ]
:if ($entry~"^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}") do={
:if ( [:len $entry ] > 0 ) do={
#:log info "debug_entry=$entry"
/ip firewall address-list add list=$addressListName address=$entry;
}
}
} while=($lineEnd < $contentLen);
} else={
:log info "There no DNS in list"
}