Commit Graph
59 Commits
Author SHA1 Message Date
rzuastiandClaude Opus 4.7 251c06277e Add pagination to the devices list screen
Mirror the notifications list paging pattern (offset/limit, fetch one
extra row to detect the next page, First/Prev/Next controls) across the
devices DB query, REST endpoint, API client and UI. Also add a First
page button to the notifications pagination row.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 13:07:27 -04:00
rzuastiandClaude Sonnet 4.6 c6fdf9e181 Centralize networking helpers in utils::network module
Move select_interface and MAC-resolution logic (resolve_mac_address,
parse_proc_net_arp, probe_mac) out of the device_finders modules into a
single utils::network utility so future scanners can reuse them. Rename
resolve to resolve_mac_address and make parse_proc_net_arp private.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 09:58:45 -04:00
rzuastiandClaude Opus 4.7 ca83009944 Add passive mDNS/Bonjour discovery scanner
Introduce a second discovery module that passively listens for mDNS
multicast announcements (224.0.0.251:5353) and feeds discovered devices
into the existing devices/events/notifications pipeline, running in its
own task alongside the ARP scanner.

Since mDNS carries an IP and hostname but no MAC (the device key), the
module resolves IP->MAC via the OS ARP cache with a targeted ARP-probe
fallback. The advertised hostname is stored in a new optional `name`
column on devices (blank for ARP-only devices); the single `update`
writes `name` only when set so ARP rescans never clobber it. Device
names are included in event/notification messages.

Adds a GET /api/mdns_scanner/status endpoint (is_listening, devices_seen,
last_device_seen_seconds_ago) wired into OpenAPI, an optional
[mdns_scanner] config section, and the corresponding Nix module option.
Also aligns the Nix module's stale `timings` section with the current
`arp_scanner` schema.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 09:37:33 -04:00
rzuastiandClaude Sonnet 4.6 08f2dc8340 Auto-detect network interface when not configured
If no interface is set in the config, the ARP scanner now picks the
first non-loopback, up, IPv4-enabled interface automatically. The
setting is optional in the TOML config, sample config, and Nix module.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-29 07:35:25 -04:00
rzuastiandClaude Sonnet 4.6 251d8a479e Redesign Home screen with device summary and scanner status
Adds a responsive Home screen combining the notification list with a
device summary panel and ARP scanner status, visible side-by-side on
wide screens and stacked on narrow ones.

Backend:
- New GET /api/devices/summary endpoint returning registered device
  counts and "seen in last 24h / 7 days" breakdowns by registration
  status
- Migration 07 adds indexes on (is_registered) and (last_seen,
  is_registered) so summary queries use index range scans instead of
  full table scans

Frontend:
- HomeScreen replaces NotificationList, embedding notifications,
  device summary card, and ArpScannerCard in a LayoutBuilder-driven
  two-column (≥700 px) or single-column layout
- ArpScannerCard extracted to a shared public widget reused by both
  HomeScreen and StatusScreen
- Nav rail entry renamed to "Home" with home icon

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 19:10:08 -04:00
rzuastiandClaude Sonnet 4.6 020c7d2c49 Add ARP scanner status API endpoint and rename scanner module
Renames scanner.rs to arp_scanner.rs to future-proof for additional scanner
types. Renames the [timings] config section to [arp_scanner] and simplifies
field names (arp_sender_timeout -> sender_timeout, arp_scan_duration ->
scan_duration). Introduces arp_scanner_status module to track whether the
scan is actively running or sleeping, and exposes this via a new
GET /api/arp_scanner/status endpoint returning is_running,
running_for_seconds, and next_run_in_seconds.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 17:57:26 -04:00
rzuastiandClaude Sonnet 4.6 23b8858259 Auto-populate device_type from vendor mapping on first device discovery
Loads vendor-device-type.json at compile time (same pattern as mac-vendors-export.json)
and sets device_type when a new device is detected by the ARP scanner.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 16:30:54 -04:00
rzuastiandClaude Sonnet 4.6 b4e226d716 Update TODO and regenerate vendor-device-type mapping with LLM classifications
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 16:17:16 -04:00
rzuastiandClaude Sonnet 4.6 55b5f9ad30 Add LLM classification to vendor update script and update dev shell
Adds --llm flag to update_mac_vendors to classify unmatched vendors via
Claude Haiku 4.5, and --skip-download to reuse existing vendor DB.
Adds the anthropic Python package to the Nix dev shell. Updates CLAUDE.md
with the new script command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 16:08:14 -04:00
rzuastiandClaude Sonnet 4.6 752b6f95fd Expand vendor keyword rules for broader device-type coverage
Adds high-precision keyword fallbacks to the classification rules:
- network_appliance: broadband, wifi, wlan, modem (standalone)
- server: storage, nas
- home_security: surveillance (standalone)
- tv: streaming (standalone)
- phone: handset, cellular

Classified vendors: 374 → 502 (+34%).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 14:50:14 -04:00
rzuastiandClaude Sonnet 4.6 50cc2a9d53 Add MAC vendor update script and vendor-to-device-type mapping
Introduces backend/data/update_mac_vendors, an executable Python 3 script
that downloads the latest MAC vendor database from maclookup.app and
generates vendor-device-type.json — a mapping of vendor names to device
types (phone, laptop, tablet, server, tv, printer, network_appliance,
home_security, home_appliance, watch, pc, gaming_console) used for
auto-assigning device type on first detection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 14:43:04 -04:00
rzuastiandClaude Sonnet 4.6 dcb0bcaed1 Update docs, TODO progress, and add run/db helper scripts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 11:28:13 -04:00
rzuastiandClaude Sonnet 4.6 e1287e5a0f Use server-side date filtering for device event history chart
The device event history chart previously fetched all events and filtered
client-side. This wires the existing created_from API parameter to the
frontend so filtering happens in the backend.

Also fixes a bug where the Today filter returned no results: rusqlite was
storing datetimes with a space separator ("YYYY-MM-DD HH:MM:SS+00:00")
while SQL filters used RFC 3339 with a T separator, causing string
comparisons to fail for same-day events. All datetime storage across
device_events, devices, and notifications is now consistently RFC 3339.
A migration converts existing records.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 10:51:19 -04:00
rzuastiandClaude Sonnet 4.6 2e8604a354 Add created_from date filter to device events list endpoint
Filters events at the query level using the existing composite index
(mac_address, created_on DESC), so no schema changes are needed.
Adds two unit tests covering the filtered and unfiltered cases.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 10:16:24 -04:00
rzuastiandClaude Sonnet 4.6 40685837b0 Add indexes on notifications table for query performance
Adds two indexes to eliminate full table scans at scale:
- idx_notifications_created_on (created_on DESC) for purge and unfiltered listing
- idx_notifications_is_new_created_on (is_new, created_on DESC) for filtered listing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 09:06:19 -04:00
rzuastiandClaude Sonnet 4.6 c7e1678407 Add retention policy for device_events and notifications
Purges records older than a configurable window (default 365d) once per day.
Also adds a composite index on device_events(mac_address, created_on DESC) for
efficient scan history queries at scale, and fixes a non-deterministic pagination
order by adding id as a tiebreaker to ORDER BY.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 09:00:36 -04:00
rzuastiandClaude Sonnet 4.6 888f18603f Add device_events table and scan history API endpoint
Records a DeviceEvent row on every scan: NewDevice when a device is first
seen, DeviceSeen on subsequent scans. Exposes GET /api/devices/{mac}/events
with pagination, ordered by date descending.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 21:22:13 -04:00
rzuastiandClaude Sonnet 4.6 47a76c4bf8 Fix run_tests.sh to use sudo with explicit CARGO_HOME
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 20:07:28 -04:00
rzuastiandClaude Sonnet 4.6 e7d075ec29 Add owner and device type filters to device list
Owner filter uses a server-side substring match (LIKE '%VALUE%');
device type filter matches the stored value exactly, sending an
empty string for unknown/unclassified devices. Both filters combine
with the existing registration status chip via AND logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 19:46:19 -04:00
rzuastiandClaude Sonnet 4.6 2da339a2b0 Add device detail screen and navigate to it from notifications and devices
- New /devices/:macAddress route showing all device fields with Register/Forget actions
- Device list items are now tappable; popup menu gains a "View details" item
- Notification list items with a linked device are tappable; popup menu gains a "View device" item
- Backend: new DB migration adds optional mac_address column to notifications
- Device-related notifications (NewDeviceFound, DeviceOnlineAfterTime, DeviceChanged) now store the triggering device's MAC address

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 18:24:35 -04:00
rzuastiandClaude Sonnet 4.6 3094753587 Add Register and Forget actions to devices list
Adds a context menu to each device card with contextual actions:
- Unregistered devices show a Register option (dialog with owner field
  and device type dropdown)
- Registered devices show a Forget option (confirmation dialog)

Also fixes CORS to allow PUT and DELETE methods, adds device type
tooltips on the icon, and renames the "New" filter/badge to
"Not registered".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:33:24 -04:00
rzuastiandClaude Sonnet 4.6 cb2b3c6af7 Fix all clippy warnings in the Rust backend
Addresses all 31 warnings emitted by cargo clippy: redundant field
names in struct initialisers, unnecessary unwrap after is_some checks
(replaced with if-let), needless borrows, filter+next replaced with
find, iter().count() replaced with len(), clone on Copy type, and
manual match-to-Option replaced with .ok().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 13:48:33 -04:00
rzuastiandClaude Sonnet 4.6 44d593fccc Add OpenAPI documentation via Utoipa
Annotates all API handlers and model structs with Utoipa macros to generate
an OpenAPI 3.0 spec at runtime. Serves an interactive Swagger UI at /api/docs
and the raw JSON spec at /api/docs/openapi.json, both publicly accessible
outside the auth middleware.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 13:36:05 -04:00
rzuastiandClaude Sonnet 4.6 bda7b87cc7 Add mark all as old API endpoint for notifications
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 11:55:30 -04:00
rzuastiandClaude Sonnet 4.6 c04e76157e Add run.sh and fix run_tests.sh to use user's cargo cache
Add run.sh script to start the backend (erases db, runs cargo with sudo
using user's CARGO_HOME to avoid full recompilation). Remove sudo from
cargo test in run_tests.sh for the same reason.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 10:21:43 -04:00
rzuastiandClaude Sonnet 4.6 8153a216b9 Add mark as new API endpoint for notifications
POST /api/notifications/{id}/mark_as_new sets is_new=1, allowing a notification to be flagged as unread after it has been read.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 10:13:56 -04:00
rzuasti b8db6db83b Filters working on notifications 2026-03-04 16:22:00 -05:00
rzuasti 63ac1d04d5 Backend list notifications now supports pagination. Frontend
notification list is inifinite and lazy
2026-03-04 11:05:24 -05:00
rzuasti dc2521da65 Settings working on front-end and with it the notifications list 2026-03-03 12:20:57 -05:00
rzuasti e6b5594226 Refactored events to notifications on front-end, added prefutils to read
shared  preferences.
2026-03-02 13:59:50 -05:00
rzuasti 2d64efa44b Frontend events are being returned from the API (yey!) 2026-02-27 12:28:16 -05:00
rzuasti 874a70969f Externalized web server config 2026-02-26 16:30:51 -05:00
rzuasti 7f754b3d17 Added API key validation on requests 2026-02-26 12:19:58 -05:00
rzuasti c50cd81be9 Added several endpoints to devices, mostly there! 2026-02-26 10:08:41 -05:00
rzuasti 884738196b Web server split into modules 2026-02-26 08:31:48 -05:00
rzuasti d3d8681626 TODO 2026-02-25 15:58:32 -05:00
rzuasti 9ff6c9ec7e List devices API working 2026-02-25 15:54:19 -05:00
rzuasti f45a22a892 Added list devices to database handler 2026-02-25 12:54:39 -05:00
rzuasti be38d2b15f Typo 2026-02-25 09:13:02 -05:00
rzuasti f88e02478a enhanced device database structure, added methods to device db module
and unit tests
2026-02-24 17:25:57 -05:00
rzuasti 5ca3b61dae Added endpoints to read notification and to read without flagging as old 2026-02-23 19:45:19 -05:00
rzuasti 03d2e6c9b1 Improved notifications structure and now saving notifications to
database when triggered
2026-02-23 13:23:36 -05:00
rzuasti e38b875052 Added notification read and insert from database 2026-02-23 11:04:57 -05:00
rzuasti 47788a6738 Refactored errors from String to custom error types 2026-02-23 09:57:22 -05:00
rzuasti 203d0dd98e List notifications endpoint working 2026-02-19 11:24:23 -05:00
rzuasti 5085bc0848 List notifications working 2026-02-19 10:57:04 -05:00
rzuasti e0e05823d1 Fixing tests 2026-02-19 10:49:38 -05:00
rzuasti 54e6dba496 Testing setup working, settings moved to a singleton and initialized on
main.
2026-02-18 11:23:20 -05:00
rzuasti 93b27c7205 About to change clap usage to builder (instead of derive) 2026-02-18 09:35:05 -05:00
rzuasti bc6a613a23 Trying to setup tests 2026-02-17 19:34:26 -05:00