Fix DNS routing on some devices

This commit is contained in:
M66B 2017-02-25 20:09:00 +01:00
parent 7084e90261
commit 624d3156e2
2 changed files with 11 additions and 3 deletions

View File

@ -993,6 +993,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
} catch (Throwable ignored) {
}
// Use default DNS servers when no two custom DNS servers specified
if (listDns.size() <= 1)
for (String def_dns : sysDns)
try {

View File

@ -265,11 +265,18 @@ public class Util {
}
public static List<String> getDefaultDNS(Context context) {
List<String> listDns = new ArrayList<>();
// Needed to route DNS into VPN on some devices
listDns.add("8.8.8.8");
String dns1 = jni_getprop("net.dns1");
String dns2 = jni_getprop("net.dns2");
List<String> listDns = new ArrayList<>();
listDns.add(TextUtils.isEmpty(dns1) ? "8.8.8.8" : dns1);
listDns.add(TextUtils.isEmpty(dns2) ? "8.8.4.4" : dns2);
if (!TextUtils.isEmpty(dns1))
listDns.add(dns1);
if (!TextUtils.isEmpty(dns2))
listDns.add(dns2);
return listDns;
}