diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-09-24 21:38:58 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-09-24 21:38:58 +0200 |
commit | 8334fe93f1e9610176f4bf13e429b5459cfd96ed (patch) | |
tree | 1d1c2c2ad1dd4fb804ccec4955446923c91bafaf | |
parent | 92752d5e54902682777b0cb15fb0c480e5796ba2 (diff) |
slightly refactor dns resolver
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Resolver.java | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/Resolver.java b/src/main/java/de/pixart/messenger/utils/Resolver.java index c405a8397..ddff9cb59 100644 --- a/src/main/java/de/pixart/messenger/utils/Resolver.java +++ b/src/main/java/de/pixart/messenger/utils/Resolver.java @@ -13,6 +13,8 @@ import java.util.List; import de.measite.minidns.DNSClient; import de.measite.minidns.DNSName; +import de.measite.minidns.Question; +import de.measite.minidns.Record; import de.measite.minidns.dnssec.DNSSECResultNotAuthenticException; import de.measite.minidns.dnsserverlookup.AndroidUsingExec; import de.measite.minidns.hla.DnssecResolverApi; @@ -150,18 +152,12 @@ public class Resolver { } private static <D extends Data> ResolverResult<D> resolveWithFallback(DNSName dnsName, Class<D> type, boolean validateHostname) throws IOException { + final Question question = new Question(dnsName, Record.TYPE.getType(type)); if (!validateHostname) { - return ResolverApi.INSTANCE.resolve(dnsName, type); + return ResolverApi.INSTANCE.resolve(question); } try { - final ResolverResult<D> 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()); + return DnssecResolverApi.INSTANCE.resolveDnssecReliable(question); } catch (DNSSECResultNotAuthenticException e) { Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + ": error resolving " + type.getSimpleName() + " with DNSSEC. Trying DNS instead.", e); } catch (IOException e) { @@ -169,7 +165,7 @@ public class Resolver { } 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(question); } private static boolean validateHostname() { |