Hi, I don't understand one thing about your script: if I import a file of 8MB I only import part of it.refreshed old glory code
:global thefile ""{ :local url "https://www.iwik.org/ipcountry/US.cidr" :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) }}:put [:len $thefile]
Is it due to a RouterOS limitation or your script?
I'm so sorry for the inconvenience.
Myscript:
Code:
: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"}
Statistics: Posted by Kataius — Tue Feb 27, 2024 10:46 am