From a954e32b1673f5816f460dc1d434d148f35821ac Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 19 Sep 2015 17:31:24 +0200 Subject: let DnsHelper provide a fallback solution --- src/main/java/eu/siacs/conversations/utils/DNSHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/eu/siacs/conversations/utils') diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index 863cfb66b..f3c4f79a2 100644 --- a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java @@ -7,6 +7,7 @@ import android.net.LinkProperties; import android.net.Network; import android.os.Build; import android.os.Bundle; +import android.os.Parcelable; import android.util.Log; import java.io.IOException; @@ -46,13 +47,19 @@ public class DNSHelper { public static Bundle getSRVRecord(final Jid jid, Context context) throws IOException { final String host = jid.getDomainpart(); final List servers = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDnsServers(context) : getDnsServersPreLollipop(); - Bundle b = null; + Bundle b = new Bundle(); for(InetAddress server : servers) { b = queryDNS(host, server); if (b.containsKey("values")) { return b; } } + if (!b.containsKey("values")) { + Log.d(Config.LOGTAG,"all dns queries failed. provide fallback A record"); + ArrayList values = new ArrayList<>(); + values.add(createNamePortBundle(host,5222)); + b.putParcelableArrayList("values",values); + } return b; } -- cgit v1.2.3