From 5525132bc49fd5f796472c5454e92fd302d68923 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 15 Jul 2026 16:38:07 +0200 Subject: [PATCH] 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 ... --- doc/netwatch-dns.md | 2 +- netwatch-dns.rsc | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/netwatch-dns.md b/doc/netwatch-dns.md index 1e2fbe9f..fff768ea 100644 --- a/doc/netwatch-dns.md +++ b/doc/netwatch-dns.md @@ -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) diff --git a/netwatch-dns.rsc b/netwatch-dns.rsc index 9cab84e7..a1c6b0f6 100644 --- a/netwatch-dns.rsc +++ b/netwatch-dns.rsc @@ -3,7 +3,7 @@ # Copyright (c) 2022-2026 Christian Hesse # 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") . \