mirror of https://github.com/M66B/NetGuard.git
Delay expiring DNS info
This commit is contained in:
parent
f83d03e615
commit
e3cdfaa297
|
@ -1684,12 +1684,12 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
|
|
||||||
boolean exists = mapUidIPFilters.get(key).containsKey(iname);
|
boolean exists = mapUidIPFilters.get(key).containsKey(iname);
|
||||||
if (!exists || !mapUidIPFilters.get(key).get(iname).isBlocked()) {
|
if (!exists || !mapUidIPFilters.get(key).get(iname).isBlocked()) {
|
||||||
IPRule rule = new IPRule(key, name + "/" + iname, block, time + ttl);
|
IPRule rule = new IPRule(key, name + "/" + iname, block, time, ttl);
|
||||||
mapUidIPFilters.get(key).put(iname, rule);
|
mapUidIPFilters.get(key).put(iname, rule);
|
||||||
if (exists)
|
if (exists)
|
||||||
Log.w(TAG, "Address conflict " + key + " " + daddr + "/" + dresource);
|
Log.w(TAG, "Address conflict " + key + " " + daddr + "/" + dresource);
|
||||||
} else if (exists) {
|
} else if (exists) {
|
||||||
mapUidIPFilters.get(key).get(iname).updateExpires(time + ttl);
|
mapUidIPFilters.get(key).get(iname).updateExpires(time, ttl);
|
||||||
if (dname != null && ttl > 60 * 1000L)
|
if (dname != null && ttl > 60 * 1000L)
|
||||||
Log.w(TAG, "Address updated " + key + " " + daddr + "/" + dresource);
|
Log.w(TAG, "Address updated " + key + " " + daddr + "/" + dresource);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3247,13 +3247,15 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
private IPKey key;
|
private IPKey key;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean block;
|
private boolean block;
|
||||||
private long expires;
|
private long time;
|
||||||
|
private long ttl;
|
||||||
|
|
||||||
public IPRule(IPKey key, String name, boolean block, long expires) {
|
public IPRule(IPKey key, String name, boolean block, long time, long ttl) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.expires = expires;
|
this.time = time;
|
||||||
|
this.ttl = ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlocked() {
|
public boolean isBlocked() {
|
||||||
|
@ -3261,17 +3263,20 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExpired() {
|
public boolean isExpired() {
|
||||||
return System.currentTimeMillis() > this.expires;
|
return System.currentTimeMillis() > (this.time + this.ttl * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateExpires(long expires) {
|
public void updateExpires(long time, long ttl) {
|
||||||
this.expires = Math.max(this.expires, expires);
|
this.time = time;
|
||||||
|
this.ttl = ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
IPRule other = (IPRule) obj;
|
IPRule other = (IPRule) obj;
|
||||||
return (this.block == other.block && this.expires == other.expires);
|
return (this.block == other.block &&
|
||||||
|
this.time == other.time &&
|
||||||
|
this.ttl == other.ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue