From 67bc032ccc19a78897f550b8eb4af41abaf8999e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 9 Jul 2017 18:03:26 +0200 Subject: [PATCH] fixed fallback to normal DNS query after DNSSEC failed --- .../java/eu/siacs/conversations/utils/Resolver.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index 6c01f1743..d3e0f757e 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -93,16 +93,22 @@ public class Resolver { private static ResolverResult resolveWithFallback(DNSName dnsName, Class type) throws IOException { try { - return DnssecResolverApi.INSTANCE.resolveDnssecReliable(dnsName, type); + final ResolverResult r = DnssecResolverApi.INSTANCE.resolveDnssecReliable(dnsName, type); + if (r.wasSuccessful()) { + if (r.getAnswers().isEmpty() && type.equals(SRV.class)) { + Log.d(Config.LOGTAG,Resolver.class.getSimpleName()+": resolving SRV records of "+dnsName.toString()+" with DNSSEC yielded empty result"); + } + return r; + } + Log.d(Config.LOGTAG,Resolver.class.getSimpleName()+": error resolving "+type.getSimpleName()+" with DNSSEC. Trying DNS instead.",r.getResolutionUnsuccessfulException()); } catch (DNSSECResultNotAuthenticException e) { Log.d(Config.LOGTAG,Resolver.class.getSimpleName()+": error resolving "+type.getSimpleName()+" with DNSSEC. Trying DNS instead.",e); - return ResolverApi.INSTANCE.resolve(dnsName, type); } catch (IOException e) { throw e; } catch (Throwable throwable) { Log.d(Config.LOGTAG,Resolver.class.getSimpleName()+": error resolving "+type.getSimpleName()+" with DNSSEC. Trying DNS instead.",throwable); - return ResolverApi.INSTANCE.resolve(dnsName, type); } + return ResolverApi.INSTANCE.resolve(dnsName, type); } public static class Result implements Comparable {