Skip to content

Add a slow wide sweep of loopback ports outside the watched range - #14

Merged
sallaumen merged 3 commits into
mainfrom
claude/wide-sweep-73dc87
Nov 7, 2026
Merged

sallaumen merged 3 commits into
mainfrom
claude/wide-sweep-73dc87

Conversation

@sallaumen

@sallaumen sallaumen commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

What

A background wide sweep finds services outside the watched range (for example 8080 or 64xxx), plus a small Other ports panel at the bottom left with an on/off switch.

  • LocalWebMonitorex.Sweeper: a supervised GenServer, separate from Monitor/Scanner. It walks 127.0.0.1 ports 1–65535, skipping the watched range and the dashboard port. It probes 32 ports per batch with at most 4 concurrent probes and a 4 s timeout per probe, pauses 1 s between batches, and waits 1 h between passes. The first pass starts 1 min after boot. Probing runs in a TaskSupervisor task, so the GenServer always answers. Measured locally: ~24 ports/s, so a full pass takes ~45 min, and the dev BEAM stayed at ~0.2% CPU.
  • Findings (Sweeper.Finding) record whether a port answers HTTP (scheme, status, title) or only TCP, plus the listener's process name from ProcessInspector (one lsof/ps call per batch that found something). No screenshots.
  • PortProbe gains a :tcp_only result. PortProbe.Http returns it for listeners that answer neither HTTP nor HTTPS. It now also treats a loopback self-connection (source port == target port, which can happen when sweeping the ephemeral range) as closed, so no phantom ports show up. Scanner still ignores everything but {:ok, service}.
  • Preference: Settings.read_sweep/save_sweep, stored as on/off in ~/.config/localwebmonitorex/sweep (override: LOCALWEBMONITOREX_SWEEP_CONFIG). It is validated before writing, and a missing or invalid file means on. It defaults to on because the owner asked for this, and the rate is fixed, low and loopback-only. Sweeper.set_enabled/1 saves the switch and applies it at once: turning it off kills the running batch and clears findings, and turning it on starts a pass immediately, without a restart.
  • Panel (LocalWebMonitorexWeb.SweepPanel): a collapsed chip ("Other ports", count, % or next time, "Off") expands into progress or the next pass time, the list of found ports (HTTP status or TCP, process name, open link for HTTP), and the role=switch toggle. + prefills the watched-range form to cover that port and opens Settings without saving anything.
  • Updater: the smoke instance writes off to its throwaway sweep file.
  • Rules: CLAUDE.md, AGENTS.md and the README describe the new boundary. The main scan still probes only the watched range. Sweeper is the single approved exception, and it stays loopback-only, paced and switchable. The endpoint stays on 127.0.0.1.

Validation

  • TDD: settings_test, port_probe/http_test, new sweeper_test (exclusion, TCP/HTTP plus process names, pacing between batches, pass interval, closed ports dropped, off stops immediately and on restarts, off at start) and dashboard_live_sweep_test (collapse/expand, list, toggle persists, the + hint does not save).
  • mix test (92 tests after the sync, 0 failures), mix format --check-formatted, mix compile --warnings-as-errors, node --test assets/js/theme.test.mjs, test/shell/update_from_main_test.sh.
  • WebKit via Playwright MCP on PORT=4105 with a scratch sweep file, at 1440 px and 375 px in light and dark: no horizontal overflow (scrollWidth == 375), 44 px touch targets on mobile, switch exposed as switch "Wide sweep", no console errors. The only console warnings were preview captures, because this worktree has no node_modules. Screenshots were not committed.

Notes

  • Synced with main after Redesign the overview around scan status and honest limits #11 (merge 5511181). The panel uses the redesign tokens and .badge styles. On desktop the collapsed chip sits at the foot of the rail, which reserves 92 px for it, and opens into a card above. Below 760 px it sits in the page flow before the footer, so it never covers content. Escape closes it. Re-checked in WebKit at 1440, 900 and 375 px, light and dark. The page has no horizontal overflow, and the chip does not overlap the rail card or the footer. There were no console errors.
  • Dev shares ~/.config/localwebmonitorex/ with the installed instance. Toggling the sweep in dev writes the shared sweep file unless LOCALWEBMONITOREX_SWEEP_CONFIG is set.

🤖 Generated with Claude Code

sallaumen and others added 3 commits November 6, 2026 17:38
A supervised Sweeper walks 127.0.0.1 ports 1-65535 apart from the main
scan, skipping the watched range and the dashboard port. It probes 32
ports per batch, 4 at a time, pauses a second between batches, and
waits an hour between passes. Findings record TCP or HTTP status and the
listener's process name; no screenshots are taken.

The HTTP probe now reports :tcp_only for listeners that answer neither
HTTP nor HTTPS, and treats a loopback self-connection as closed.

An "Other ports" panel at the bottom left shows progress, the next pass
and the ports found, with a switch that stops or restarts the sweep at
once. The switch is saved in its own `sweep` file, on by default. The
updater's smoke instance keeps the sweep off.

CLAUDE.md, AGENTS.md and the README describe the new boundary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts resolved in favor of the redesign: scan progress keeps its
scan-strip styles and the render tests use render_assigns, now with the
sweep assigns.

The Other ports panel now uses the redesign's tokens and badges. On
desktop the collapsed chip sits at the foot of the rail, which reserves
room for it, and opens into a card above it. Below 760 px it is in the
page flow before the footer, so it never covers content. Escape closes
the open panel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sweeper started each batch with Task.Supervisor.async_nolink, so
when the sweeper stopped, a batch in flight kept probing. In tests it
outlived its recorder and crashed. The sweeper now traps exits and
shuts down the running batch in terminate/2.

The sweeper tests are now deterministic. The findings test sweeps 5
ports instead of 931. The pacing test uses a 60 s pause instead of
racing a 200 ms one. The probe recorder is supervised, so ExUnit stops
it after the sweeper. A new test checks that stopping the sweeper
stops its probes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sallaumen
sallaumen merged commit b89d679 into main Nov 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant