Можно переделать под что-то своё.
URL для примера, меняем на своё
Важно: что бы url был прямой, без редиректов.
Важно: Должно быть аналогичное правило для перенаправления трафика в интересующие ресурсы через туннель для chain output в mangle
Код: Выделить всё
:local testUrls {"https://www.vk.com/login"; "https://www.ok.ru/login"; "https://www.rt.ru/about"}
:local successCount 0
:local counter 1
:foreach url in=$testUrls do={
:local fileName ($counter . ".check")
:local fetchStatus false
# Attempt to fetch the URL with error handling
:do {
/tool fetch url=$url mode=https keep-result=yes dst-path=$fileName
:delay 2s
# Check if the file was created successfully
:if ([:len [/file find name=$fileName]] > 0) do={
:set successCount ($successCount + 1)
/log info message="File successfully created: $fileName for URL: $url"
:set fetchStatus true
} else={
/log error message="File not found after fetch for URL: $url"
}
} on-error={
/log error message="Fetch failed for URL: $url"
}
# Increment the counter for the next URL
:set counter ($counter + 1)
}
# Check if at least 2 URLs were successful
:if ($successCount >= 2) do={
/log warning message="Connection check passed. $successCount URLs were successful. Enable mangle rules for bypass blocking sites "
/ip/firewall/mangle/ set [find where comment="mark routing to Tunnel from MANUAL address list sites only HTTP/S"] disabled=no
} else={
/log error message="Connection to at least 2 URLs failed. Only $successCount URLs were successful. disable mangle rules for bypass blocking sites"
/ip/firewall/mangle/ set [find where comment="mark routing to Tunnel from MANUAL address list sites only HTTP/S"] disabled=yes
}
# Delay before file removal
:delay 10s
# Remove all temporary files
:for i from=1 to=($counter - 1) do={
:local fileName ($i . ".check")
:if ([:len [/file find name=$fileName]] > 0) do={
/file remove [find name=$fileName]
/log info message="Temporary file removed: $fileName"
}
}