This is inspired by a patch from Chris Thompson, and https://lists.isc.org/pipermail/bind-users/2020-January/102596.html.