Show number of domains for IP address

This commit is contained in:
M66B 2017-03-08 22:04:43 +01:00
parent 74793484b4
commit 90875c5805
2 changed files with 9 additions and 5 deletions

View File

@ -53,6 +53,7 @@ public class AdapterAccess extends CursorAdapter {
private int colTime;
private int colAllowed;
private int colBlock;
private int colCount;
private int colSent;
private int colReceived;
private int colConnections;
@ -71,6 +72,7 @@ public class AdapterAccess extends CursorAdapter {
colTime = cursor.getColumnIndex("time");
colAllowed = cursor.getColumnIndex("allowed");
colBlock = cursor.getColumnIndex("block");
colCount = cursor.getColumnIndex("count");
colSent = cursor.getColumnIndex("sent");
colReceived = cursor.getColumnIndex("received");
colConnections = cursor.getColumnIndex("connections");
@ -105,6 +107,7 @@ public class AdapterAccess extends CursorAdapter {
long time = cursor.getLong(colTime);
int allowed = cursor.getInt(colAllowed);
int block = cursor.getInt(colBlock);
int count = cursor.getInt(colCount);
long sent = cursor.isNull(colSent) ? -1 : cursor.getLong(colSent);
long received = cursor.isNull(colReceived) ? -1 : cursor.getLong(colReceived);
int connections = cursor.isNull(colConnections) ? -1 : cursor.getInt(colConnections);
@ -130,7 +133,7 @@ public class AdapterAccess extends CursorAdapter {
}
String dest = Util.getProtocolName(protocol, version, true) +
" " + daddr + (dport > 0 ? "/" + dport : "");
" " + daddr + (dport > 0 ? "/" + dport : "") + (count > 1 ? " ?" + count : "");
SpannableString span = new SpannableString(dest);
span.setSpan(new UnderlineSpan(), 0, dest.length(), 0);
tvDest.setText(span);

View File

@ -679,10 +679,11 @@ public class DatabaseHelper extends SQLiteOpenHelper {
SQLiteDatabase db = this.getReadableDatabase();
// There is a segmented index on uid
// There is no index on time for write performance
String query = "SELECT ID AS _id, *";
query += " FROM access";
query += " WHERE uid = ?";
query += " ORDER BY time DESC";
String query = "SELECT a.ID AS _id, a.*";
query += ", (SELECT COUNT(*) FROM dns d WHERE d.resource = (SELECT d1.resource FROM dns d1 WHERE d1.qname = a.daddr)) count";
query += " FROM access a";
query += " WHERE a.uid = ?";
query += " ORDER BY a.time DESC";
query += " LIMIT 50";
return db.rawQuery(query, new String[]{Integer.toString(uid)});
} finally {