Hub (FastAPI + no-build web UI): - Network health: live probe/target matrix, status strips, incidents - Probes: add (with install command), rename, remove, latency and throughput charts - Clients merged from AdGuard, DHCP, query log and probe ARP tables; names, categories, suspicious flag, notes, per-client DNS requests - Query log, domain detail (clients, related subdomains), blocked domains via the AdGuard Home /control API Probe: tests peers (ping, HTTP, throughput), gateway, LAN and public DNS, internet URLs and an optional VPS; buffers results while the hub is down. Gateway and ARP from /proc/net on Linux, route/arp on macOS. Install: install.sh (hub) and install-probe.sh (generated from it), each in docker mode (compose; default on Linux hosts) or native mode (venv + systemd or launchd; default on macOS and in LXC). Both modes deploy with an update command that checks the new commit and rolls back on failure. CLAUDE.md carries shared context for Claude Code sessions on each machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
3.3 KiB
JavaScript
67 lines
3.3 KiB
JavaScript
// The DNS query log from AdGuard Home, with search, result filter and client filter.
|
|
import { debounce, el, segmented } from '../ui.js';
|
|
import { get } from '../api.js';
|
|
import { ms, when } from '../fmt.js';
|
|
import { adguardProblem, clientLink, domainLink, resultChip, screen, fill } from '../common.js';
|
|
|
|
export function mount(root, ctx) {
|
|
const params = ctx.query;
|
|
let status = params.get('status') || 'all';
|
|
const client = params.get('client') || '';
|
|
const ip = params.get('ip') || '';
|
|
const domain = params.get('domain') || '';
|
|
const search = el('input.input', { type: 'search', value: params.get('q') || '', placeholder: 'Domain or client', 'aria-label': 'Search queries' });
|
|
const seg = segmented([['all', 'All'], ['blocked', 'Blocked'], ['allowed', 'Allowed']], status, (v) => { status = v; sync(); load(true); }, 'Result');
|
|
const filterChip = client || ip || domain
|
|
? el('span.chip.accent', {}, `${client ? 'Client' : ip ? 'IP' : 'Domain'}: ${client || ip || domain} `,
|
|
el('a', { href: '/queries', 'aria-label': 'Clear filter', style: 'color:inherit;text-decoration:none' }, '✕'))
|
|
: null;
|
|
const ui = screen(root, [search, seg, filterChip, el('span.spacer'), el('button.btn', { type: 'button', onclick: () => load(true) }, 'Refresh')]);
|
|
const tbody = el('tbody');
|
|
const more = el('button.btn', { type: 'button', onclick: () => load() }, 'Load older');
|
|
let cursor = '', count = 0, seq = 0;
|
|
|
|
function sync() {
|
|
const u = new URLSearchParams(location.search);
|
|
search.value ? u.set('q', search.value) : u.delete('q');
|
|
status !== 'all' ? u.set('status', status) : u.delete('status');
|
|
history.replaceState({}, '', `/queries${u.size ? `?${u}` : ''}`);
|
|
}
|
|
search.addEventListener('input', debounce(() => { sync(); load(true); }, 350));
|
|
|
|
async function load(reset = false) {
|
|
const my = ++seq;
|
|
if (reset) { cursor = ''; count = 0; }
|
|
more.disabled = true;
|
|
ui.setStatus('Loading…');
|
|
try {
|
|
const r = await get('/api/dns/queries', { search: search.value.trim(), status, client, ip, domain, older_than: cursor, limit: 100 });
|
|
if (my !== seq) return;
|
|
if (reset) tbody.replaceChildren();
|
|
cursor = r.oldest;
|
|
count += r.rows.length;
|
|
tbody.append(...r.rows.map((q) => el(`tr${q.device?.suspicious ? '.flagged' : ''}`, {},
|
|
el('td.nowrap', { title: q.time }, when(q.ts)),
|
|
el('td', {}, clientLink(q.client, q.device, q.client_name)),
|
|
el('td.domain', {}, domainLink(q.domain)),
|
|
el('td.mono', {}, q.type),
|
|
el('td', {}, resultChip(q)),
|
|
el('td.num', {}, ms(q.elapsed_ms)))));
|
|
if (!ui.body.querySelector('table')) {
|
|
fill(ui.body, el('div.table-wrap', {}, el('table.table', {},
|
|
el('thead', {}, el('tr', {}, ...['Time', 'Client', 'Domain', 'Type', 'Result', { t: 'Response', c: 'num' }].map((h) => el('th', h.c ? { class: h.c } : {}, h.t || h)))), tbody)),
|
|
el('div.more', {}, more));
|
|
}
|
|
if (!count) fill(ui.body, el('div.empty', {}, 'No queries match.'));
|
|
more.hidden = r.done || !cursor;
|
|
ui.setStatus(`${count} queries${r.done ? ' · end of the AdGuard log' : ''}`);
|
|
} catch (err) {
|
|
if (my !== seq) return;
|
|
fill(ui.body, adguardProblem(err));
|
|
ui.setStatus(err.message, 'error');
|
|
} finally {
|
|
more.disabled = false;
|
|
}
|
|
}
|
|
load(true);
|
|
}
|