mirror of https://github.com/M66B/NetGuard.git
Simplification
This commit is contained in:
parent
be05d4c9d5
commit
4b97ef0145
|
@ -136,19 +136,19 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
db.execSQL("CREATE TABLE log (" +
|
db.execSQL("CREATE TABLE log (" +
|
||||||
" ID INTEGER PRIMARY KEY AUTOINCREMENT" +
|
" ID INTEGER PRIMARY KEY AUTOINCREMENT" +
|
||||||
", time INTEGER NOT NULL" +
|
", time INTEGER NOT NULL" +
|
||||||
", version INTEGER NULL" +
|
", version INTEGER" +
|
||||||
", protocol INTEGER NULL" +
|
", protocol INTEGER" +
|
||||||
", flags TEXT" +
|
", flags TEXT" +
|
||||||
", saddr TEXT" +
|
", saddr TEXT" +
|
||||||
", sport INTEGER NULL" +
|
", sport INTEGER" +
|
||||||
", daddr TEXT" +
|
", daddr TEXT" +
|
||||||
", dport INTEGER NULL" +
|
", dport INTEGER" +
|
||||||
", dname TEXT NULL" +
|
", dname TEXT" +
|
||||||
", uid INTEGER NULL" +
|
", uid INTEGER" +
|
||||||
", data TEXT" +
|
", data TEXT" +
|
||||||
", allowed INTEGER NULL" +
|
", allowed INTEGER" +
|
||||||
", connection INTEGER NULL" +
|
", connection INTEGER" +
|
||||||
", interactive INTEGER NULL" +
|
", interactive INTEGER" +
|
||||||
");");
|
");");
|
||||||
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)");
|
||||||
|
@ -167,11 +167,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
", daddr TEXT NOT NULL" +
|
", daddr TEXT NOT NULL" +
|
||||||
", dport INTEGER NOT NULL" +
|
", dport INTEGER NOT NULL" +
|
||||||
", time INTEGER NOT NULL" +
|
", time INTEGER NOT NULL" +
|
||||||
", allowed INTEGER NULL" +
|
", allowed INTEGER" +
|
||||||
", block INTEGER NOT NULL" +
|
", block INTEGER NOT NULL" +
|
||||||
", sent INTEGER NULL" +
|
", sent INTEGER" +
|
||||||
", received INTEGER NULL" +
|
", received INTEGER" +
|
||||||
", connections INTEGER NULL" +
|
", connections INTEGER" +
|
||||||
");");
|
");");
|
||||||
db.execSQL("CREATE UNIQUE INDEX idx_access ON access(uid, version, protocol, daddr, dport)");
|
db.execSQL("CREATE UNIQUE INDEX idx_access ON access(uid, version, protocol, daddr, dport)");
|
||||||
db.execSQL("CREATE INDEX idx_access_daddr ON access(daddr)");
|
db.execSQL("CREATE INDEX idx_access_daddr ON access(daddr)");
|
||||||
|
@ -186,7 +186,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
", qname TEXT NOT NULL" +
|
", qname TEXT NOT NULL" +
|
||||||
", aname TEXT NOT NULL" +
|
", aname TEXT NOT NULL" +
|
||||||
", resource TEXT NOT NULL" +
|
", resource TEXT NOT NULL" +
|
||||||
", ttl INTEGER NULL" +
|
", ttl INTEGER" +
|
||||||
");");
|
");");
|
||||||
db.execSQL("CREATE UNIQUE INDEX idx_dns ON dns(qname, aname, resource)");
|
db.execSQL("CREATE UNIQUE INDEX idx_dns ON dns(qname, aname, resource)");
|
||||||
db.execSQL("CREATE INDEX idx_dns_resource ON dns(resource)");
|
db.execSQL("CREATE INDEX idx_dns_resource ON dns(resource)");
|
||||||
|
@ -240,33 +240,33 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
try {
|
try {
|
||||||
if (oldVersion < 2) {
|
if (oldVersion < 2) {
|
||||||
if (!columnExists(db, "log", "version"))
|
if (!columnExists(db, "log", "version"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN version INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN version INTEGER");
|
||||||
if (!columnExists(db, "log", "protocol"))
|
if (!columnExists(db, "log", "protocol"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN protocol INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN protocol INTEGER");
|
||||||
if (!columnExists(db, "log", "uid"))
|
if (!columnExists(db, "log", "uid"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN uid INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN uid INTEGER");
|
||||||
oldVersion = 2;
|
oldVersion = 2;
|
||||||
}
|
}
|
||||||
if (oldVersion < 3) {
|
if (oldVersion < 3) {
|
||||||
if (!columnExists(db, "log", "port"))
|
if (!columnExists(db, "log", "port"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN port INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN port INTEGER");
|
||||||
if (!columnExists(db, "log", "flags"))
|
if (!columnExists(db, "log", "flags"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN flags TEXT");
|
db.execSQL("ALTER TABLE log ADD COLUMN flags TEXT");
|
||||||
oldVersion = 3;
|
oldVersion = 3;
|
||||||
}
|
}
|
||||||
if (oldVersion < 4) {
|
if (oldVersion < 4) {
|
||||||
if (!columnExists(db, "log", "connection"))
|
if (!columnExists(db, "log", "connection"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN connection INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN connection INTEGER");
|
||||||
oldVersion = 4;
|
oldVersion = 4;
|
||||||
}
|
}
|
||||||
if (oldVersion < 5) {
|
if (oldVersion < 5) {
|
||||||
if (!columnExists(db, "log", "interactive"))
|
if (!columnExists(db, "log", "interactive"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN interactive INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN interactive INTEGER");
|
||||||
oldVersion = 5;
|
oldVersion = 5;
|
||||||
}
|
}
|
||||||
if (oldVersion < 6) {
|
if (oldVersion < 6) {
|
||||||
if (!columnExists(db, "log", "allowed"))
|
if (!columnExists(db, "log", "allowed"))
|
||||||
db.execSQL("ALTER TABLE log ADD COLUMN allowed INTEGER NULL");
|
db.execSQL("ALTER TABLE log ADD COLUMN allowed INTEGER");
|
||||||
oldVersion = 6;
|
oldVersion = 6;
|
||||||
}
|
}
|
||||||
if (oldVersion < 7) {
|
if (oldVersion < 7) {
|
||||||
|
@ -320,9 +320,9 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
if (oldVersion < 17) {
|
if (oldVersion < 17) {
|
||||||
if (!columnExists(db, "access", "sent"))
|
if (!columnExists(db, "access", "sent"))
|
||||||
db.execSQL("ALTER TABLE access ADD COLUMN sent INTEGER NULL");
|
db.execSQL("ALTER TABLE access ADD COLUMN sent INTEGER");
|
||||||
if (!columnExists(db, "access", "received"))
|
if (!columnExists(db, "access", "received"))
|
||||||
db.execSQL("ALTER TABLE access ADD COLUMN received INTEGER NULL");
|
db.execSQL("ALTER TABLE access ADD COLUMN received INTEGER");
|
||||||
oldVersion = 17;
|
oldVersion = 17;
|
||||||
}
|
}
|
||||||
if (oldVersion < 18) {
|
if (oldVersion < 18) {
|
||||||
|
@ -334,7 +334,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
}
|
}
|
||||||
if (oldVersion < 19) {
|
if (oldVersion < 19) {
|
||||||
if (!columnExists(db, "access", "connections"))
|
if (!columnExists(db, "access", "connections"))
|
||||||
db.execSQL("ALTER TABLE access ADD COLUMN connections INTEGER NULL");
|
db.execSQL("ALTER TABLE access ADD COLUMN connections INTEGER");
|
||||||
oldVersion = 19;
|
oldVersion = 19;
|
||||||
}
|
}
|
||||||
if (oldVersion < 20) {
|
if (oldVersion < 20) {
|
||||||
|
|
Loading…
Reference in New Issue