fix(devices): exclude homelab guests (network_hosts + bc:24:11 OUI) from discovery
The scan was surfacing every Proxmox container/host as a 'new' device. Filter the scan against the network_hosts inventory and the Proxmox guest OUI so the devices band stays IoT/personal-only, per the spec. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
// One discovery cycle: scan → upsert → mark-absent → prune. Deps injected for
|
||||
// tests. Prune only runs after a successful, non-empty scan, so a failed scan
|
||||
// can never reap rows.
|
||||
// One discovery cycle: scan → drop homelab guests → upsert → mark-absent → prune.
|
||||
// Homelab containers/hosts are excluded from the IoT/personal devices band — they
|
||||
// live in the network_hosts inventory, not here. We drop any MAC that's in
|
||||
// network_hosts OR carries the Proxmox guest OUI (bc:24:11). Deps injected for
|
||||
// tests. Prune only runs after a successful, non-empty scan.
|
||||
import { runScan } from './scan.js';
|
||||
import * as devices from '../db/repos/lan_devices.js';
|
||||
import * as netHosts from '../db/repos/network_hosts.js';
|
||||
import { log } from '../log.js';
|
||||
|
||||
export async function runDeviceScanCycle({ scan = runScan, repo = devices } = {}) {
|
||||
const rows = await scan();
|
||||
const HOMELAB_OUI = 'bc:24:11'; // Proxmox auto-generated guest MAC prefix
|
||||
|
||||
export async function runDeviceScanCycle({ scan = runScan, repo = devices, hosts = netHosts } = {}) {
|
||||
const inventory = new Set((await hosts.all()).map(h => String(h.mac || '').toLowerCase()));
|
||||
const rows = (await scan()).filter(r => !inventory.has(r.mac) && !r.mac.startsWith(HOMELAB_OUI));
|
||||
if (!rows.length) {
|
||||
log.warn('device scan returned no hosts; skipping upsert/prune');
|
||||
log.warn('device scan found no non-homelab hosts; skipping upsert/prune');
|
||||
return { seen: 0 };
|
||||
}
|
||||
await repo.upsertScan(rows);
|
||||
|
||||
Reference in New Issue
Block a user