diff --git a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java index 3d23f157..6fa434b0 100644 --- a/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java +++ b/app/src/main/java/eu/faircode/netguard/DatabaseHelper.java @@ -922,7 +922,7 @@ public class DatabaseHelper extends SQLiteOpenHelper { query += " LEFT JOIN dns AS d"; query += " ON d.qname = a.daddr"; query += " WHERE a.block >= 0"; - query += " AND d.time + d.ttl >= " + now; + query += " AND (d.time IS NULL OR d.time + d.ttl >= " + now + ")"; if (dname != null) query += " AND a.daddr = ?"; diff --git a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java index 08ffe7b9..79aa6134 100644 --- a/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java +++ b/app/src/main/java/eu/faircode/netguard/ServiceSinkhole.java @@ -1577,11 +1577,11 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS int version = cursor.getInt(colVersion); int protocol = cursor.getInt(colProtocol); String daddr = cursor.getString(colDAddr); - String dresource = cursor.getString(colResource); + String dresource = (cursor.isNull(colResource) ? null : cursor.getString(colResource)); int dport = cursor.getInt(colDPort); boolean block = (cursor.getInt(colBlock) > 0); - long time = cursor.getLong(colTime); - long ttl = cursor.getLong(colTTL); + long time = (cursor.isNull(colTime) ? new Date().getTime() : cursor.getLong(colTime)); + long ttl = (cursor.isNull(colTTL) ? 7 * 24 * 3600 * 1000L : cursor.getLong(colTTL)); if (isLockedDown(last_metered)) { String[] pkg = getPackageManager().getPackagesForUid(uid);