misc/sonar: new plugin, dashboard widget that visualises the live firewall log

Aperta
#5,922 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
8/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, php
Ambito
backend, frontend

Direzione di ricerca

This is a proposal for a new plugin, not a defined change. Start with the existing Firewall widget that reads /api/diagnostics/firewall/stream_log and with the proposed layout under misc/sonar (Makefile, src/opnsense/www/js/widgets/Sonar.js, Metadata/Sonar.xml). Done means maintainers answer the four questions on category, GeoIP handling, existing country-lookup APIs and the map data, and the author splits the work into reviewable PRs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

incomplete

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

Is your feature request related to a problem? Please describe.

Hi, before opening a PR I'd like your feedback on a new plugin. Our community is crucial in shaping the ongoing development of our open-source OPNsense® software products.

The Firewall widget shows the live log as a list of lines. That is precise, but it is hard to see at a glance where traffic is coming from, which ports are being probed and what the firewall is blocking right now.

Describe the solution you'd like

What it is

Sonar is a dashboard widget that turns the live firewall log into a picture of what is happening right now. It reads the same stream as the Firewall widget (/api/diagnostics/firewall/stream_log) and only uses existing read-only core endpoints (interface names, interface overview, system resources, CPU and traffic streams). It changes no configuration.

Views, switched by a small selector in the widget header:

View What it shows
Sonar a tilted radar disc with a rotating sweep; each remote address is a blip (green pass, red block, blue NAT), inbound on the outer ring, outbound on the inner one
Map a world map with animated arcs from origin to destination and the country flag; blocked inbound connections fly as small missiles and are intercepted on a shield around the firewall
Flow a live Sankey diagram: origin (country or local hosts) → interface → service (port) → decision (pass, NAT or the blocking rule)
Citadel the network as an isometric city under an energy dome: one district per interface, one building per local host; blocked inbound traffic hits the dome as meteors, outbound traffic rises as beams
Black hole the firewall as a black hole; each remote address is a star in orbit, and every blocked connection spirals into the event horizon; stars of the same country form constellations
Digital rain one column per destination port; each event falls as a drop coloured by action, blocked drops shatter on the firewall floor, so a port scan shows up as a storm

Common to all views:

  • a side panel when the widget is wide: events and blocks in the last 60 s, inbound/outbound split, top attacking countries, most targeted ports, top blocking rules, last attacks;
  • hover shows country, address, port, direction and rule label; click opens Live View filtered on that address, like the Firewall widget;
  • a fullscreen button, and optional sound cues (off by default);
  • plain Canvas 2D, no new JavaScript libraries; animation pauses when the tab is hidden; colours come from the active theme, so it works with light and dark themes; reduced motion is respected.
Package
misc/sonar/                      (or another category you prefer)
  Makefile                       PLUGIN_NAME=sonar, PLUGIN_VERSION=1.0
  pkg-descr
  src/opnsense/www/js/widgets/Sonar.js (+ one file per view)
  src/opnsense/www/js/widgets/Metadata/Sonar.xml
  src/opnsense/www/js/widgets/Sonar-map.json   Natural Earth 1:110m outlines, public domain, ~140 KB
  + a small read-only API for the country lookup (below)

About 4,300 lines of JavaScript for the six views. I'm happy to split it: first PR with the Sonar view only, then the map and flow views, then the others.

Dependencies and setup (for users)
  1. Logging on rules. Sonar only sees what the firewall logs: enable "Log packets" on the rules you want to watch (Firewall → Rules); default block rules already log.

  2. Country data (Map, Flow, Black hole, flags). Uses the free MaxMind GeoLite2 database with the user's own account, exactly as described in the MaxMind GeoIP setup how-to:

    1. create a free account at maxmind.com (GeoLite2 sign-up);
    2. generate a license key ("My License Key", answer "no" to geoipupdate);
    3. in Firewall → Aliases → GeoIP settings, enter https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=<LICENSE_KEY>&suffix=zip and Apply;
    4. create at least one GeoIP alias, so the lists are downloaded.

    Without it the Sonar, Citadel and Digital rain views work normally; the country-based views show a hint pointing to those settings.

  3. No other packages. No external services, no telemetry, nothing leaves the firewall.

GeoIP data

The plugin will not ship any GeoIP-derived data. MaxMind requires every user of their lists to have an account and accept their terms, so countries are resolved on the firewall from the lists each user already downloads with their own key (/usr/local/share/GeoIP/alias/), through a small read-only endpoint in the plugin. In my local build the widget used a compact table generated from my own lists; that file stays out of the package.

Questions before I open the PR
  1. Is a plugin the right place, and is misc/sonar (package os-sonar) a good category and name?
  2. Is resolving countries server-side from the user's own GeoIP lists acceptable, and should the widget show the attribution "This product includes GeoLite2 data created by MaxMind" when the map is visible?
  3. Is there already an API that maps an address to a country from the GeoIP alias data that I should reuse instead of adding one?
  4. Is shipping the public-domain map outlines as a static JSON file next to the widget fine?

I'm happy to maintain the plugin. Maintainer: igortoledo007 (please reach me here on GitHub).

Describe alternatives you've considered

  • Proposing it to core: as an optional plugin it stays out of the way of users who don't want it, like the Tailscale, vnStat and Wake on LAN widgets.
  • The Insight / Reporting pages: they show history and totals, not what is happening right now.

Additional context

AI disclosure

Developed with AI assistance: Claude (Anthropic), a mix of the Fable 5.2 and Opus 5.5 models. I reviewed and tested it on my own OPNsense 26.7.9 firewall.

Screenshots

Taken on my own firewall running OPNsense 26.7.9 (Forja theme from #5921), fullscreen except the first; addresses, interface, gateway and host names are blurred.

  1. The widget on the dashboard (Map view)
  2. Sonar
  3. Map
  4. Flow
  5. Citadel
  6. Black hole
  7. Digital rain
00-sonar-dashboard 01-sonar-radar 02-sonar-map 03-sonar-flow 04-sonar-citadel 05-sonar-black-hole 06-sonar-digital-rain
Lingua principale
PHP
Stelle
1.2k
Fork
926
Merge medio
1g 10h
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opnsense/plugins

Tutte le issue di opnsense/plugins

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.