diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-09-19 17:31:24 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-09-19 17:31:24 +0200 |
commit | a954e32b1673f5816f460dc1d434d148f35821ac (patch) | |
tree | f29476df813e74ac161a9a6d1ddc53bccfb1a5b1 /src/main/java/eu/siacs/conversations/utils | |
parent | 069ddddbc14a83b0b466a4d62033d17bb322b155 (diff) |
let DnsHelper provide a fallback solution
Diffstat (limited to 'src/main/java/eu/siacs/conversations/utils')
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/DNSHelper.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/utils/DNSHelper.java b/src/main/java/eu/siacs/conversations/utils/DNSHelper.java index 863cfb66..f3c4f79a 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<InetAddress> 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<Parcelable> values = new ArrayList<>(); + values.add(createNamePortBundle(host,5222)); + b.putParcelableArrayList("values",values); + } return b; } |