Files
UpSnap/docker-compose.yml
T
Mike Pastore b5fd864320 feat: optional per-device IP address tracking via periodic ARP scan (#1763)
* feat: optional per-device ip address tracking via periodic arp scan

Adds a per-device "Track IP address" toggle (disabled by default) and a
global cron interval setting. When enabled, upsnap periodically arp-scans
the local subnets of opted-in devices with nmap and updates a device's ip
address whenever its mac address is found at a different one. Subnets are
skipped unless directly attached to the host, so routed devices are never
scanned. Uses the same nmap + CAP_NET_RAW requirements as the existing
network scan feature; no new privileges needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test: cover ip tracking subnet helpers and nmap xml parsing

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: extract ip tracking into its own package and expand test coverage

Move the arp scan sweep out of cronjobs into a new iptracking package with
two entry points: TrackAllSubnets (the cron sweep) and TrackOneSubnet (a
single validated scan). Device lookup is now by mac address across all
tracked devices, with updates constrained to the device's own subnet.

The scannability check becomes networking.ValidateScannableSubnet, which
reports why a subnet can't be scanned and accepts any subnet overlapping a
directly attached network, so sub-blocks of an attached prefix are now
scannable. The mac-to-ip mapping moves to networking as Nmaprun.MacToIP.

Cover the subnet guard, mac normalization, skip paths, and sweep
orchestration with tests against a stubbed scanner and a real migrated
schema.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: pause tracking sweeps while nobody is connected

With lazy_ping turned on, the periodic tracking sweep now skips its tick
while no realtime clients are connected, just like the ping cron, and owes
a catch-up sweep to the next client that connects: the realtime connect
hook runs one sweep only when a tick was actually skipped (or none has run
since boot), so page reloads during active use trigger nothing. This
extends lazy_ping's meaning from "pause pings when idle" to "pause
periodic network activity when idle"; the setting's description is updated
accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* ui: move lazy ping section below ip tracking in settings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* disable toggle when tracking is disabled

* fix: load private store

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Maxi Quoß <maxi@quoss.org>
2026-08-27 20:21:51 +02:00

31 lines
1.5 KiB
YAML

services:
upsnap:
cap_add:
- NET_RAW # NET_RAW is required for privileged ping, network device scan and ip address tracking (nmap)
cap_drop:
- ALL
container_name: upsnap
image: ghcr.io/seriousm4x/upsnap:5 # images are also available on docker hub: seriousm4x/upsnap:5
network_mode: host # host is required for WOL magic packets
restart: unless-stopped
volumes:
- ./data:/app/pb_data
# # To use a non-root user, create the mountpoint first (mkdir data) so that it has the right permission.
# user: 1000:1000
# environment:
# - TZ=Europe/Berlin # Set container timezone for cron schedules
# - UPSNAP_HTTP_LISTEN=127.0.0.1:8090
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
# - UPSNAP_PING_PRIVILEGED=true # Default is true. Set to false for unprivileged ping
# For Linux hosts, unprivileged pings REQUIRES the host to set 'sysctl net.ipv4.ping_group_range="0 2147483647"'
# or another suitable value to grant the group access to send ping and WOL magic packets.
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
# security_opt:
# - no-new-privileges=true
# # dns is used for name resolution during network scan
# dns:
# - 192.18.0.1
# - 192.18.0.2