Fixed local hosts resolution can't be shutdown

This commit is contained in:
PeratX 2017-05-01 11:58:41 +08:00
parent 87454eabe0
commit 2a4cfbfd79
2 changed files with 5 additions and 4 deletions

View File

@ -113,14 +113,14 @@ public class Daedalus extends Application {
};
public static void initHostsResolver() {
if (Daedalus.getPrefs().getBoolean("settings_local_host_resolve", false)) {
if (Daedalus.getPrefs().getBoolean("settings_local_host_resolution", false)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int permission = ActivityCompat.checkSelfPermission(Daedalus.getInstance(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (MainActivity.getInstance() != null) {
int permission = ActivityCompat.checkSelfPermission(Daedalus.getInstance(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.getInstance(), PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
}
} else {
} else if (permission != PackageManager.PERMISSION_GRANTED) {
return;
}
}

View File

@ -179,6 +179,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
}
dnsQueryTimes = 0;
HostsResolver.clean();
System.gc();
}
@ -210,7 +211,7 @@ public class DaedalusVpnService extends VpnService implements Runnable {
boolean advanced = Daedalus.getPrefs().getBoolean("settings_advanced_switch", false);
boolean statisticQuery = Daedalus.getPrefs().getBoolean("settings_count_query_times", false);
localHostsResolve = Daedalus.getPrefs().getBoolean("settings_local_host_resolve", false);
localHostsResolve = Daedalus.getPrefs().getBoolean("settings_local_host_resolution", false);
Log.d(TAG, "tun0 add " + format + " pServ " + primaryServer + " sServ " + secondaryServer);
Inet4Address primaryDNSServer = InetAddressUtil.ipv4From(primaryServer);
Inet4Address secondaryDNSServer = InetAddressUtil.ipv4From(secondaryServer);