Last active
July 9, 2024 22:11
-
-
Save uablacklist/b0e73deb75f2a1c43f035c59e5401e8c to your computer and use it in GitHub Desktop.
Добавляет IP подсети, заблокированные украинским правительством, из https://uablacklist.net в список адресов вашего Mikrotik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:local apiPrefix "https://uablacklist.net/subnets_mikrotik_" | |
:local tempFile "uablacklist.txt" | |
:local listName "uablacklist" | |
/log info "removing existing '$listName'..." | |
:put "removing existing '$listName'..." | |
/ip firewall address-list remove [/ip firewall address-list find list=$listName] | |
# mikrotik can't load >4KB file inside a variable, so backend contains file pieces which we download and parse one by one | |
:local i 0 | |
:local isEnd false | |
:do { | |
:local apiPath "$apiPrefix$i.txt" | |
/log info "fetching UA blacklist registry piece ($apiPath)..." | |
:put "fetching UA blacklist registry piece ($apiPath)..." | |
:local contentLen 0 | |
:local content "" | |
:do { | |
/tool fetch url=$apiPath dst-path=$tempFile | |
:set content [/file get [/file find name=$tempFile] contents] | |
:set contentLen [:len $content] | |
} on-error={ | |
/log info "no more pieces"; | |
:put "no more pieces" | |
:set isEnd true | |
} | |
:local lineEnd 0 | |
:local line "" | |
:local lastEnd 0 | |
:local company "" | |
:while ($lastEnd < $contentLen) do { | |
:set lineEnd [:find $content "\n" $lastEnd ] | |
:set line [:pick $content $lastEnd $lineEnd] | |
:set lastEnd ($lineEnd+1) | |
:local entry [:pick $line 0 ($lineEnd-1)] | |
:if ([:pick $line 0 1] != "#") do={ | |
:if ([:len $entry ] > 0) do={ | |
/log info "add '$entry' subnet of '$company' to list '$listName'..."; | |
:put "add '$entry' subnet of '$company' to list '$listName'..."; | |
:do { | |
/ip firewall address-list add list=$listName address=$entry comment=$company | |
} on-error={ | |
/log info "failed to add '$entry' subnet of '$company' to list '$listName', probably, it's duplication error."; | |
:put "failed to add '$entry' subnet of '$company' to list '$listName', probably, it's duplication error." | |
} | |
} | |
} else={ | |
:set company [:pick $line 2 ($lineEnd) ] | |
} | |
} | |
:set i (i+1) | |
} while (!$isEnd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Сайт работает.
Возможно, у вашего провайдера он заблокирован, проверьте как разолвится его DNS имя и попробуйте перенаправить роутинг к нему сразу в VPN.
Но вообще рекомендую не список, а перейти на BGP https://antifilter.network/bgp