diff options
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/AndroidUsingLinkProperties.java | 11 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/utils/Resolver.java | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/utils/AndroidUsingLinkProperties.java b/src/main/java/de/pixart/messenger/utils/AndroidUsingLinkProperties.java index d844824cf..a740188b8 100644 --- a/src/main/java/de/pixart/messenger/utils/AndroidUsingLinkProperties.java +++ b/src/main/java/de/pixart/messenger/utils/AndroidUsingLinkProperties.java @@ -5,6 +5,7 @@ import android.content.Context; import android.net.ConnectivityManager; import android.net.LinkProperties; import android.net.Network; +import android.net.NetworkInfo; import android.net.RouteInfo; import android.os.Build; @@ -39,11 +40,17 @@ public class AndroidUsingLinkProperties extends AbstractDNSServerLookupMechanism return new String[0]; } List<String> servers = new ArrayList<>(); + int vpnOffset = 0; for (Network network : networks) { LinkProperties linkProperties = connectivityManager.getLinkProperties(network); + NetworkInfo networkInfo = connectivityManager.getNetworkInfo(network); if (linkProperties != null) { - if (hasDefaultRoute(linkProperties)) { - servers.addAll(0, getIPv4First(linkProperties.getDnsServers())); + if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_VPN) { + final List<String> tmp = getIPv4First(linkProperties.getDnsServers()); + servers.addAll(0, tmp); + vpnOffset += tmp.size(); + } else if (hasDefaultRoute(linkProperties)) { + servers.addAll(vpnOffset, getIPv4First(linkProperties.getDnsServers())); } else { servers.addAll(getIPv4First(linkProperties.getDnsServers())); } diff --git a/src/main/java/de/pixart/messenger/utils/Resolver.java b/src/main/java/de/pixart/messenger/utils/Resolver.java index 5a90cb30c..42324daed 100644 --- a/src/main/java/de/pixart/messenger/utils/Resolver.java +++ b/src/main/java/de/pixart/messenger/utils/Resolver.java @@ -118,9 +118,7 @@ public class Resolver { } catch (Throwable throwable) { Log.d(Config.LOGTAG, Resolver.class.getSimpleName() + "error resolving fallback records", throwable); } - if (results.size() == 0) { - results.add(Result.createDefault(dnsName)); - } + results.add(Result.createDefault(dnsName)); return results; } |