mirror of https://github.com/M66B/NetGuard.git
Added indices to facilitate searching
This commit is contained in:
parent
4434a61280
commit
f20b586710
|
@ -34,7 +34,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
private static final String TAG = "NetGuard.Database";
|
private static final String TAG = "NetGuard.Database";
|
||||||
|
|
||||||
private static final String DB_NAME = "Netguard";
|
private static final String DB_NAME = "Netguard";
|
||||||
private static final int DB_VERSION = 12;
|
private static final int DB_VERSION = 13;
|
||||||
|
|
||||||
private static boolean once = true;
|
private static boolean once = true;
|
||||||
private static List<LogChangedListener> logChangedListeners = new ArrayList<>();
|
private static List<LogChangedListener> logChangedListeners = new ArrayList<>();
|
||||||
|
@ -97,6 +97,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
");");
|
");");
|
||||||
db.execSQL("CREATE INDEX idx_log_time ON log(time)");
|
db.execSQL("CREATE INDEX idx_log_time ON log(time)");
|
||||||
db.execSQL("CREATE INDEX idx_log_dest ON log(daddr)");
|
db.execSQL("CREATE INDEX idx_log_dest ON log(daddr)");
|
||||||
|
db.execSQL("CREATE INDEX idx_log_dport ON log(dport)");
|
||||||
|
db.execSQL("CREATE INDEX idx_log_dname ON log(dname)");
|
||||||
db.execSQL("CREATE INDEX idx_log_uid ON log(uid)");
|
db.execSQL("CREATE INDEX idx_log_uid ON log(uid)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +175,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
createTableAccess(db);
|
createTableAccess(db);
|
||||||
oldVersion = 12;
|
oldVersion = 12;
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 13) {
|
||||||
|
db.execSQL("CREATE INDEX idx_log_dport ON log(dport)");
|
||||||
|
db.execSQL("CREATE INDEX idx_log_dname ON log(dname)");
|
||||||
|
oldVersion = 13;
|
||||||
|
}
|
||||||
|
|
||||||
if (oldVersion == DB_VERSION) {
|
if (oldVersion == DB_VERSION) {
|
||||||
db.setVersion(oldVersion);
|
db.setVersion(oldVersion);
|
||||||
|
|
|
@ -29,19 +29,19 @@ public class ResourceRecord {
|
||||||
public String AName;
|
public String AName;
|
||||||
public String Resource;
|
public String Resource;
|
||||||
public int TTL;
|
public int TTL;
|
||||||
private static DateFormat formater = SimpleDateFormat.getDateTimeInstance();
|
private static DateFormat formatter = SimpleDateFormat.getDateTimeInstance();
|
||||||
|
|
||||||
public ResourceRecord() {
|
public ResourceRecord() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return formater.format(
|
return formatter.format(
|
||||||
new Date(Time).getTime()) +
|
new Date(Time).getTime()) +
|
||||||
" Q " + QName +
|
" Q " + QName +
|
||||||
" A " + AName +
|
" A " + AName +
|
||||||
" R " + Resource +
|
" R " + Resource +
|
||||||
" TTL " + TTL +
|
" TTL " + TTL +
|
||||||
" " + formater.format(new Date(Time + TTL * 1000L).getTime());
|
" " + formatter.format(new Date(Time + TTL * 1000L).getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue