get('kea'); $settings = modules()->settings('kea'); $fallback = $module['db_defaults'] ?? []; $metadataFallback = is_array($module['metadata_db_defaults'] ?? null) ? $module['metadata_db_defaults'] : []; $metadataConfig = is_array($settings['metadata_db'] ?? null) ? array_replace($metadataFallback, $settings['metadata_db']) : $metadataFallback; $source = (string)($_GET['source'] ?? $_POST['source'] ?? 'reservation'); $source = $source === 'lease' ? 'lease' : 'reservation'; $id = (int)($_GET['id'] ?? $_POST['id'] ?? 0); $error = null; $notice = null; $host = null; $metadataRepo = null; $groups = []; $availableIpsByGroup = []; $checks = []; $hostKey = ''; try { $pdo = modules()->modulePdo('kea', $fallback); if (empty($metadataConfig['driver']) || empty($metadataConfig['dbname'])) { throw new RuntimeException('Nexus DHCP Zusatzdatenbank ist nicht konfiguriert.'); } $metadataRepo = new KeaHostMetadataRepository(Database::createFromArray($metadataConfig)); $metadataRepo->ensureSchema(); $groups = $metadataRepo->listGroups(); $repo = new KeaHostRepository($pdo, $metadataRepo); $host = $repo->findDisplayByKey($source, $id); if (!$host) { throw new RuntimeException('KEA Eintrag wurde nicht gefunden.'); } $hostKey = $source . ':' . (string)($host['host_id'] ?? $id); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = (string)($_POST['action'] ?? 'save_metadata'); if ($action === 'dns_lookup') { $ip = (string)($host['ipv4_address'] ?? ''); $hostname = trim((string)($host['metadata']['device_name'] ?? $host['hostname'] ?? '')); $reverse = $ip !== '' ? gethostbyaddr($ip) : ''; $forward = $hostname !== '' ? gethostbyname($hostname) : ''; $success = ($reverse !== '' && $reverse !== $ip) || ($forward !== '' && $forward !== $hostname); $metadataRepo->saveCheck($hostKey, 'dns', $success ? 'success' : 'warning', [ 'ip' => $ip, 'hostname' => $hostname, 'reverse' => $reverse, 'forward' => $forward, ]); $notice = $success ? 'DNS-Pruefung gespeichert.' : 'DNS-Pruefung gespeichert, aber kein eindeutiger Name gefunden.'; } else { $metadata = [ 'real_name' => $_POST['real_name'] ?? '', 'device_name' => $_POST['device_name'] ?? '', 'owner' => $_POST['owner'] ?? '', 'location' => $_POST['location'] ?? '', 'device_type' => $_POST['device_type'] ?? '', 'group_name' => $_POST['group_name'] ?? '', 'desired_ip' => $_POST['desired_ip'] ?? '', 'notes' => $_POST['notes'] ?? '', 'tags' => [], ]; $desiredIp = trim((string)$metadata['desired_ip']); if ($desiredIp !== '') { $newHostId = $repo->reserveDisplayEntry($host, $desiredIp, $metadata); $source = 'reservation'; $id = $newHostId; $notice = 'Zusatzdaten gespeichert und KEA-Reservierung gesetzt.'; } else { $metadataRepo->saveForHost( $id, (string)($host['dhcp_identifier'] ?? ''), (string)($host['ipv4_address'] ?? ''), $metadata ); $notice = 'Zusatzdaten gespeichert.'; } } $host = $repo->findDisplayByKey($source, $id) ?: $host; $hostKey = $source . ':' . (string)($host['host_id'] ?? $id); } $usedIps = array_diff( array_merge($repo->usedIpAddresses(), $metadataRepo->desiredIps()), [(string)($host['ipv4_address'] ?? ''), (string)($host['metadata']['desired_ip'] ?? '')] ); $availableIpsByGroup = $metadataRepo->availableIpsByGroup($usedIps); $checks = $metadataRepo->latestChecks([$hostKey])[$hostKey] ?? []; } catch (Throwable $e) { $error = $e->getMessage(); } $metadata = is_array($host['metadata'] ?? null) ? $host['metadata'] : []; $selectedGroup = (string)($metadata['group_name'] ?? ''); $selectedIp = (string)($metadata['desired_ip'] ?? ''); ?> = module_shell_header('kea', [ 'title' => 'KEA Eintrag bearbeiten', ]) ?>
Zusatzdaten werden separat von der KEA-Datenbank gespeichert.
IP = e((string)($host['ipv4_address'] ?? '')) ?> · MAC = e((string)($host['dhcp_identifier'] ?? '')) ?>
Pruefergebnisse werden in der Nexus-DHCP-Datenbank gespeichert und koennen spaeter fuer Reports genutzt werden.
Status: = e((string)($dnsCheck['status'] ?? '')) ?> · = e((string)($dnsCheck['checked_at'] ?? '')) ?>
Reverse: = e((string)($dnsResult['reverse'] ?? '-')) ?>
Forward: = e((string)($dnsResult['forward'] ?? '-')) ?>
Noch keine DNS-Pruefung gespeichert.
Vorbereitet fuer spaetere HTTP/Port-Erkennung. Noch nicht automatisch aktiv, damit keine ungewollten Scans laufen.