1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-02-24 15:21:19 +00:00

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(); db.beginTransactionNonExclusive();
try { try {
int ttl = rr.TTL; int ttl = rr.TTL;
// Android caches DNS for 15 minutes
if (ttl < 15 * 60) if (ttl < 15 * 60)
ttl = 15 * 60; ttl = 15 * 60;
@ -834,7 +833,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
// There is a segmented index on qname // There is a segmented index on qname
String query = "SELECT ID AS _id, *"; String query = "SELECT ID AS _id, *";
query += " FROM dns"; query += " FROM dns";
query += " ORDER BY qname"; query += " ORDER BY qname, resource";
return db.rawQuery(query, new String[]{}); return db.rawQuery(query, new String[]{});
} finally { } finally {
mLock.readLock().unlock(); 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) { if (!exists || !mapUidIPFilters.get(key).get(iname).block) {
IPRule rule = new IPRule(block, time + ttl); IPRule rule = new IPRule(block, time + ttl);
mapUidIPFilters.get(key).put(iname, rule); 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); Log.w(TAG, "Address conflict uid=" + uid + " " + daddr + " " + dresource + "/" + dport);
}
} else } else
Log.w(TAG, "Address not numeric " + name); Log.w(TAG, "Address not numeric " + name);
} catch (UnknownHostException ex) { } catch (UnknownHostException ex) {