From 62e01cbcbf508601679da601077ad79a23498ba8 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Fri, 4 Oct 2024 12:44:50 +0200 Subject: [PATCH] fix: don't fail when upstream DNS returns no AAAA records workaround for silly recursors --- nyacme/hook.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nyacme/hook.py b/nyacme/hook.py index cdc9792..e88a71e 100644 --- a/nyacme/hook.py +++ b/nyacme/hook.py @@ -82,7 +82,13 @@ def resolve4(addr: str) -> list[str]: return list(map(str, res)) def resolve6(addr: str) -> list[str]: - res = dns.resolver.resolve(addr, 'AAAA') + try: + res = dns.resolver.resolve(addr, 'AAAA') + except dns.resolver.NoAnswer: + # workaround for silly recursors that return NOERROR + # empty response when they don't support IPv6 + log.warning('no IPv6 nameservers returned') + res = [] return list(map(str, res))