Less VPN reloads when no DNS address set

This commit is contained in:
M66B 2016-03-03 11:09:43 +01:00
parent a055791d4a
commit e31a7f2519
2 changed files with 11 additions and 10 deletions

View File

@ -104,7 +104,7 @@ public class AdapterLog extends CursorAdapter {
try {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
dns = SinkholeService.getDns(context).get(0);
dns = InetAddress.getByName(prefs.getString("dns", Util.getDefaultDNS(context).get(0)));
vpn4 = InetAddress.getByName(prefs.getString("vpn4", "10.1.10.1"));
vpn6 = InetAddress.getByName(prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1"));
} catch (UnknownHostException ex) {

View File

@ -951,7 +951,7 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
String vpnDns = prefs.getString("dns", null);
Log.i(TAG, "DNS system=" + TextUtils.join(",", sysDns) + " VPN=" + vpnDns);
if (vpnDns != null)
if (vpnDns != null) {
try {
InetAddress dns = InetAddress.getByName(vpnDns);
if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()))
@ -959,14 +959,15 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
} catch (Throwable ignored) {
}
for (String def_dns : sysDns)
try {
InetAddress ddns = InetAddress.getByName(def_dns);
if (!listDns.contains(ddns) &&
!(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()))
listDns.add(ddns);
} catch (Throwable ignored) {
}
for (String def_dns : sysDns)
try {
InetAddress ddns = InetAddress.getByName(def_dns);
if (!listDns.contains(ddns) &&
!(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()))
listDns.add(ddns);
} catch (Throwable ignored) {
}
}
return listDns;
}