diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-07 20:54:54 +0200 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-04-07 20:54:54 +0200 |
commit | a7fd6b31e20e722a524467cd93bf65900ee7af92 (patch) | |
tree | c1fc886795ce57a6038ea64b49ceb0c6d90f0dfb | |
parent | fdfaae6f59496834e31f2081ce4602b9b31330b1 (diff) |
fix resolving IP if SRV violences RFC2782
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Resolver.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/Resolver.java b/src/main/java/de/pixart/messenger/utils/Resolver.java index aa05043e7..1f7eb4ee7 100644 --- a/src/main/java/de/pixart/messenger/utils/Resolver.java +++ b/src/main/java/de/pixart/messenger/utils/Resolver.java @@ -203,7 +203,7 @@ public class Resolver { threads.add(new Thread(() -> { final List<Result> ipv4s = resolveIp(record, A.class, result.isAuthenticData(), directTls); if (ipv4s.size() == 0) { - Result resolverResult = Result.fromRecord(record, directTls); + Result resolverResult = Result.fromRecord(record, directTls, true); resolverResult.authenticated = result.isAuthenticData(); ipv4s.add(resolverResult); } @@ -266,7 +266,8 @@ public class Resolver { try { ResolverResult<D> results = resolveWithFallback(hostname, type, authenticated); for (D record : results.getAnswersOrEmptySet()) { - Result resolverResult = Result.fromRecord(srv, directTls); + boolean ipv4 = type == A.class; + Result resolverResult = Result.fromRecord(srv, directTls, ipv4); resolverResult.authenticated = results.isAuthenticData() && authenticated; resolverResult.ip = record.getInetAddress(); list.add(resolverResult); @@ -392,16 +393,17 @@ public class Resolver { private String logID = ""; - static Result fromRecord(final SRV srv, final boolean directTls) { + static Result fromRecord(final SRV srv, final boolean directTls, final boolean ipv4) { Result result = new Result(); result.timeRequested = System.currentTimeMillis(); result.port = srv.port; result.hostname = srv.name; - try { - result.ip = InetAddress.getByName(result.hostname.toString()); - } catch (UnknownHostException e) { - result.ip = null; - e.printStackTrace(); + if (ipv4) { + try { + result.ip = InetAddress.getByName(result.hostname.toString()); + } catch (UnknownHostException e) { + e.printStackTrace(); + } } result.directTls = directTls; result.priority = srv.priority; |