mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-23 14:51:06 +00:00
Added submenu to show domain names with same IP address
This commit is contained in:
parent
808c3ca4cd
commit
ad687229a8
2 changed files with 34 additions and 1 deletions
|
@ -48,7 +48,9 @@ import android.text.style.ImageSpan;
|
|||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -635,6 +637,21 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
|
|||
Util.getProtocolName(protocol, version, false) + " " +
|
||||
daddr + (dport > 0 ? "/" + dport : ""));
|
||||
|
||||
SubMenu sub = popup.getMenu().findItem(R.id.menu_host).getSubMenu();
|
||||
boolean multiple = false;
|
||||
Cursor alt = null;
|
||||
try {
|
||||
alt = DatabaseHelper.getInstance(context).getAlternateQNames(daddr);
|
||||
while (alt.moveToNext()) {
|
||||
multiple = true;
|
||||
sub.add(Menu.NONE, Menu.NONE, 0, alt.getString(0)).setEnabled(false);
|
||||
}
|
||||
} finally {
|
||||
if (alt != null)
|
||||
alt.close();
|
||||
}
|
||||
popup.getMenu().findItem(R.id.menu_host).setEnabled(multiple);
|
||||
|
||||
markPro(popup.getMenu().findItem(R.id.menu_allow), ActivityPro.SKU_FILTER);
|
||||
markPro(popup.getMenu().findItem(R.id.menu_block), ActivityPro.SKU_FILTER);
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
// There is a segmented index on uid
|
||||
// There is no index on time for write performance
|
||||
String query = "SELECT a.ID AS _id, a.*";
|
||||
query += ", (SELECT COUNT(DISTINCT d.qname) FROM dns d WHERE d.resource = (SELECT d1.resource FROM dns d1 WHERE d1.qname = a.daddr)) count";
|
||||
query += ", (SELECT COUNT(DISTINCT d.qname) FROM dns d WHERE d.resource IN (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";
|
||||
|
@ -836,6 +836,22 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public Cursor getAlternateQNames(String qname) {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
String query = "SELECT DISTINCT d2.qname";
|
||||
query += " FROM dns d1";
|
||||
query += " JOIN dns d2";
|
||||
query += " ON d2.resource = d1.resource AND d2.id <> d1.id";
|
||||
query += " WHERE d1.qname = ?";
|
||||
query += " ORDER BY d2.qname";
|
||||
return db.rawQuery(query, new String[]{qname});
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor getDns() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue