From c400f74918a990c00d7a1688f5a1881ee024bcdb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 9 Jul 2017 19:05:23 +0200 Subject: [PATCH] prefer ipv4 over ipv6 --- src/main/java/eu/siacs/conversations/utils/Resolver.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/utils/Resolver.java b/src/main/java/eu/siacs/conversations/utils/Resolver.java index d3e0f757e..3a1ac8259 100644 --- a/src/main/java/eu/siacs/conversations/utils/Resolver.java +++ b/src/main/java/eu/siacs/conversations/utils/Resolver.java @@ -5,6 +5,7 @@ import android.support.annotation.NonNull; import android.util.Log; import java.io.IOException; +import java.net.Inet4Address; import java.net.InetAddress; import java.util.ArrayList; import java.util.Collections; @@ -157,6 +158,12 @@ public class Resolver { if (directTls == result.directTls) { if (ip == null && result.ip == null) { return 0; + } else if (ip != null && result.ip != null) { + if (ip instanceof Inet4Address && result.ip instanceof Inet4Address) { + return 0; + } else { + return ip instanceof Inet4Address ? -1 : 1; + } } else { return ip != null ? -1 : 1; }