Use max expiry on conflict, improvements

This commit is contained in:
M66B 2016-11-11 21:04:50 +01:00
parent fcafb8b43e
commit 85c77cc6af
2 changed files with 5 additions and 3 deletions

View File

@ -739,7 +739,6 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.beginTransactionNonExclusive();
try {
int ttl = rr.TTL;
// Android caches DNS for 15 minutes
if (ttl < 15 * 60)
ttl = 15 * 60;
@ -834,7 +833,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// There is a segmented index on qname
String query = "SELECT ID AS _id, *";
query += " FROM dns";
query += " ORDER BY qname";
query += " ORDER BY qname, resource";
return db.rawQuery(query, new String[]{});
} finally {
mLock.readLock().unlock();

View File

@ -1300,8 +1300,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
if (!exists || !mapUidIPFilters.get(key).get(iname).block) {
IPRule rule = new IPRule(block, time + ttl);
mapUidIPFilters.get(key).put(iname, rule);
} else if (exists)
} else if (exists) {
IPRule rule = mapUidIPFilters.get(key).get(iname);
rule.expires = Math.max(rule.expires, time + ttl);
Log.w(TAG, "Address conflict uid=" + uid + " " + daddr + " " + dresource + "/" + dport);
}
} else
Log.w(TAG, "Address not numeric " + name);
} catch (UnknownHostException ex) {