network-monitor/app/static/js/views/blocked.js
neil 54a765510a Network monitor: hub, probes, Docker and native installers
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>
2026-11-04 18:10:29 -08:00

35 lines
2.1 KiB
JavaScript

// Blocked domains: AdGuard's top blocked list plus what was blocked recently, and for whom.
import { el } from '../ui.js';
import { get } from '../api.js';
import { ago, num, pct, when } from '../fmt.js';
import { adguardProblem, clientLink, domainLink, screen, section, table, fill } from '../common.js';
export function mount(root) {
const ui = screen(root, [el('button.btn', { type: 'button', onclick: () => load() }, 'Refresh'), el('span.spacer'), el('a.btn', { href: '/queries?status=blocked' }, 'Blocked queries in the log')]);
async function load() {
ui.setStatus('Loading…');
try {
const b = await get('/api/dns/blocked');
fill(ui.body,
el('p.lede', {}, b.num_queries ? `AdGuard Home blocked ${num(b.num_blocked)} of ${num(b.num_queries)} queries (${pct(b.num_blocked / b.num_queries, 1)}) in its stats period.` : 'No AdGuard stats yet.'),
el('div.cols', {},
el('div', {}, section('Recently blocked', b.since ? `${num(b.sample)} blocked queries since ${when(b.since)}` : ''),
table(['Domain', { text: 'Times', props: { class: 'num' } }, 'Clients', 'Last'],
b.recent.map((r) => el('tr', {},
el('td', {}, domainLink(r.domain), r.rule ? el('div.small.muted.mono', {}, r.rule) : null),
el('td.num', {}, num(r.count)),
el('td', {}, el('div', { style: 'display:grid;gap:2px' }, ...r.clients.slice(0, 4).map((c) => clientLink(c.ip, c.device)),
r.clients.length > 4 ? el('span.small.muted', {}, `+${r.clients.length - 4} more`) : null)),
el('td.nowrap', {}, ago(r.last)))), { empty: 'Nothing blocked recently.' })),
el('div', {}, section('Most blocked', 'AdGuard stats period'),
table(['Domain', { text: 'Times', props: { class: 'num' } }],
b.top.map((r) => el('tr', {}, el('td', {}, domainLink(r.domain)), el('td.num', {}, num(r.count)))), { empty: 'Nothing yet.' }))),
);
ui.setStatus(`${b.recent.length} domains blocked recently`);
} catch (err) {
fill(ui.body, adguardProblem(err));
ui.setStatus(err.message, 'error');
}
}
load();
}