1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-02-07 15:23:13 +00:00

Always honor set DNS servers

This commit is contained in:
M66B 2019-09-01 20:05:23 +02:00
parent f2485d7d94
commit f632a96f11

View file

@ -1149,18 +1149,19 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
// Use system DNS servers only when no two custom DNS servers specified
if (listDns.size() < 2)
for (String def_dns : sysDns)
try {
InetAddress ddns = InetAddress.getByName(def_dns);
if (!listDns.contains(ddns) &&
!(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()) &&
(ip6 || ddns instanceof Inet4Address))
listDns.add(ddns);
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
if (listDns.size() == 2)
return listDns;
for (String def_dns : sysDns)
try {
InetAddress ddns = InetAddress.getByName(def_dns);
if (!listDns.contains(ddns) &&
!(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()) &&
(ip6 || ddns instanceof Inet4Address))
listDns.add(ddns);
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
// Remove local DNS servers when not routing LAN
boolean lan = prefs.getBoolean("lan", false);