get('kea'); $settings = modules()->settings('kea'); $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; $fallback = $module['db_defaults'] ?? []; $error = null; $notice = null; $groups = []; $availableIpsByGroup = []; $usedIps = []; try { if (empty($metadataConfig['driver']) || empty($metadataConfig['dbname'])) { throw new RuntimeException('Nexus DHCP Zusatzdatenbank ist nicht konfiguriert.'); } $metadataRepo = new KeaHostMetadataRepository(Database::createFromArray($metadataConfig)); $metadataRepo->ensureSchema(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $action = (string)($_POST['action'] ?? ''); if ($action === 'save_group') { $metadataRepo->saveGroup( (string)($_POST['name'] ?? ''), (string)($_POST['description'] ?? ''), (string)($_POST['parent_name'] ?? '') ); $notice = 'Gruppe gespeichert.'; } elseif ($action === 'add_range') { $metadataRepo->addRange( (string)($_POST['group_name'] ?? ''), (string)($_POST['start_ip'] ?? ''), (string)($_POST['end_ip'] ?? '') ); $notice = 'IP-Bereich gespeichert.'; } } $groups = $metadataRepo->listGroupsWithRanges(); $keaRepo = new KeaHostRepository(modules()->modulePdo('kea', $fallback), $metadataRepo); $usedIps = array_merge($keaRepo->usedIpAddresses(), $metadataRepo->desiredIps()); $availableIpsByGroup = $metadataRepo->availableIpsByGroup($usedIps, 4096); } catch (Throwable $e) { $error = $e->getMessage(); } $usedIpLookup = array_flip(array_filter(array_map('strval', $usedIps))); $matrixForGroup = static function (array $group) use ($usedIpLookup): array { $dots = []; foreach (($group['ranges'] ?? []) as $range) { $start = ip2long((string)($range['start_ip'] ?? '')); $end = ip2long((string)($range['end_ip'] ?? '')); if ($start === false || $end === false) { continue; } for ($ip = $start; $ip <= $end && count($dots) < 512; $ip++) { $address = long2ip($ip); if ($address === false) { continue; } $dots[] = [ 'ip' => $address, 'used' => isset($usedIpLookup[$address]), ]; } } return $dots; }; ?> = module_shell_header('kea', [ 'title' => 'KEA Gruppen', ]) ?>
Gruppen und IP-Bereiche fuer DHCP-Reservierungen.
| Gruppe | Untergruppe von | Beschreibung | Bereiche | Freie IPs | Matrix |
|---|---|---|---|---|---|
| Noch keine Gruppen definiert. | |||||
| = e((string)$group['name']) ?> | = e((string)($group['parent_name'] ?: '-')) ?> | = e((string)($group['description'] ?? '-')) ?> |
Kein Bereich
= e((string)$range['start_ip']) ?> - = e((string)$range['end_ip']) ?>
|
= e((string)count($available)) ?> |
Kein Bereich
|