netwatch-dns: check with a HTTP/2 request

We need RouterOS 7.24 for this to catch runtime errors for bad
command parameters.

Actually this would work with RouterOS 7.23 on architectures that
support http-version=http2 ...
This commit is contained in:
Christian Hesse 2026-07-15 16:38:07 +02:00
parent 8c6707befd
commit 5525132bc4
2 changed files with 15 additions and 6 deletions

View file

@ -4,7 +4,7 @@ Manage DNS and DoH servers from netwatch
[![GitHub stars](https://img.shields.io/github/stars/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=red)](https://github.com/eworm-de/routeros-scripts/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=green)](https://github.com/eworm-de/routeros-scripts/network)
[![GitHub watchers](https://img.shields.io/github/watchers/eworm-de/routeros-scripts?logo=GitHub&style=flat&color=blue)](https://github.com/eworm-de/routeros-scripts/watchers)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.22-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![required RouterOS version](https://img.shields.io/badge/RouterOS-7.24rc1-yellow?style=flat)](https://mikrotik.com/download/changelogs/)
[![Telegram group @routeros_scripts](https://img.shields.io/badge/Telegram-%40routeros__scripts-%2326A5E4?logo=telegram&style=flat)](https://t.me/routeros_scripts)
[![donate with PayPal](https://img.shields.io/badge/Like_it%3F-Donate!-orange?logo=githubsponsors&logoColor=orange&style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A4ZXBD6YS2W8J)

View file

@ -3,7 +3,7 @@
# Copyright (c) 2022-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.22
# requires RouterOS, version=7.24rc1
# requires device-mode, fetch
#
# monitor and manage dns/doh with netwatch
@ -113,11 +113,20 @@
:local I 1;
:retry {
:set I ($I ^ 1);
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
http-header-field=({ "accept: application/dns-message" }) \
url=(($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
:local Url (($DohServer->"doh-url") . "?dns=" . [ :convert to=base64 ([ :rndstr length=2 ] . \
"\01\00" . "\00\01" . "\00\00" . "\00\00" . "\00\00" . "\09doh-check\05eworm" . \
({ "\02de"; "\03net" }->$I) . "\00" . "\00\10" . "\00\01") ]) as-value ]->"data");
({ "\02de"; "\03net" }->$I) . "\00" . "\00\10" . "\00\01") ]);
:onerror Err {
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user http-version=http2 \
http-header-field=({ "accept: application/dns-message" }) url=$Url as-value ]->"data");
} do={
:if ($Err ~ "^bad parameter http-version") do={
:set Data ([ /tool/fetch check-certificate=yes-without-crl output=user \
http-header-field=({ "accept: application/dns-message" }) url=$Url as-value ]->"data");
} else={
:error $Err;
}
}
} delay=500ms max=6;
} do={
$LogPrint warning $ScriptName ("Request to DoH server " . ($DohServer->"doh-url") . \