mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
netscan: respect status field from probe payloads (offline phones now correctly marked offline)
This commit is contained in:
@@ -29,18 +29,21 @@ foreach ($devices as $d) {
|
|||||||
$mac = trim($d['mac'] ?? '');
|
$mac = trim($d['mac'] ?? '');
|
||||||
$hostname = trim($d['hostname'] ?? '');
|
$hostname = trim($d['hostname'] ?? '');
|
||||||
$vendor = trim($d['vendor'] ?? '');
|
$vendor = trim($d['vendor'] ?? '');
|
||||||
|
// Respect explicit status from probe (e.g. phone probe knows if device is offline)
|
||||||
|
// Fall back to "online" for nmap results which only report reachable hosts
|
||||||
|
$status = in_array($d['status'] ?? '', ['online','offline']) ? $d['status'] : 'online';
|
||||||
if (!$ip) continue;
|
if (!$ip) continue;
|
||||||
|
|
||||||
$discoveredIPs[] = $ip;
|
$discoveredIPs[] = $ip;
|
||||||
JarvisDB::execute(
|
JarvisDB::execute(
|
||||||
'INSERT INTO network_devices (ip, mac, hostname, status, last_seen)
|
'INSERT INTO network_devices (ip, mac, hostname, status, last_seen)
|
||||||
VALUES (?,?,?,"online",NOW())
|
VALUES (?,?,?,?,NOW())
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
mac = COALESCE(NULLIF(VALUES(mac),""), mac),
|
mac = COALESCE(NULLIF(VALUES(mac),""), mac),
|
||||||
hostname = COALESCE(NULLIF(VALUES(hostname),""), hostname),
|
hostname = COALESCE(NULLIF(VALUES(hostname),""), hostname),
|
||||||
status = "online",
|
status = VALUES(status),
|
||||||
last_seen = NOW()',
|
last_seen = NOW()',
|
||||||
[$ip, $mac ?: null, $hostname ?: $vendor ?: null]
|
[$ip, $mac ?: null, $hostname ?: $vendor ?: null, $status]
|
||||||
);
|
);
|
||||||
if ($vendor) {
|
if ($vendor) {
|
||||||
JarvisDB::execute(
|
JarvisDB::execute(
|
||||||
|
|||||||
Reference in New Issue
Block a user