mirror of https://github.com/M66B/NetGuard.git
Use alt hosts names
This commit is contained in:
parent
7f966920e6
commit
13f54700d1
|
@ -1525,6 +1525,8 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
|
||||
mapHostsBlocked.clear();
|
||||
|
||||
DatabaseHelper dh = DatabaseHelper.getInstance(ServiceSinkhole.this);
|
||||
|
||||
int count = 0;
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
|
@ -1540,6 +1542,19 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
if (words.length == 2) {
|
||||
count++;
|
||||
mapHostsBlocked.put(words[1], true);
|
||||
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = dh.getAlternateQNames(words[1]);
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
String alt = cursor.getString(0);
|
||||
mapHostsBlocked.put(alt, true);
|
||||
Log.i(TAG, words[1] + " alt " + alt);
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
} else
|
||||
Log.i(TAG, "Invalid hosts file line: " + line);
|
||||
}
|
||||
|
@ -1811,9 +1826,32 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
|||
|
||||
// Called from native code
|
||||
private void dnsResolved(ResourceRecord rr) {
|
||||
if (DatabaseHelper.getInstance(ServiceSinkhole.this).insertDns(rr)) {
|
||||
DatabaseHelper dh = DatabaseHelper.getInstance(ServiceSinkhole.this);
|
||||
if (dh.insertDns(rr)) {
|
||||
Log.i(TAG, "New IP " + rr);
|
||||
prepareUidIPFilters(rr.QName);
|
||||
|
||||
if (!mapHostsBlocked.containsKey(rr.QName)) {
|
||||
lock.writeLock().lock();
|
||||
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = dh.getAlternateQNames(rr.QName);
|
||||
while (cursor != null && cursor.moveToNext()) {
|
||||
String alt = cursor.getString(0);
|
||||
if (mapHostsBlocked.containsKey(alt)) {
|
||||
mapHostsBlocked.put(rr.QName, true);
|
||||
Log.i(TAG, "New " + alt + " alt " + rr.QName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue