Files
RouterOS/RouterOSAssistant/Core/Models/DhcpServerCommandBuilder.swift
T
KayandClaude Sonnet 5 9f2ad2c9e9 M4: VLAN-Schritt (separates virtuelles Netz)
Neuer optionaler Schritt im Einrichten-Wizard, standardmäßig
übersprungen (Toggle): legt ein VLAN-Interface auf einem gewählten
Basis-Anschluss an, mit eigenem IP-Bereich und eigenem DHCP-Server —
z.B. für Gäste/IoT. Bewusst ohne Port-Zuweisung (Access/Trunk): das
bräuchte RouterOS Bridge-VLAN-Filtering mit "set"-Operationen auf
bestehende Einträge, die unser bisheriges reines "add"-Befehlsmodell
(identisch für REST+SSH) nicht abdeckt. Wer ein VLAN auf einem
bestimmten Switch-Port braucht, muss den Trunk weiterhin manuell
einrichten. Entscheidung mit Nutzer abgestimmt.

DHCP-Befehlsbau (Adresse+Pool+Server+Netzwerk) aus dem LAN-Schritt in
DhcpServerCommandBuilder extrahiert, da jetzt zweimal identisch
gebraucht (LAN direkt, VLAN pro Eintrag).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HReLXMbmPvtQ23p1iWiJNW
2026-09-11 22:13:31 +02:00

58 lines
2.2 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
/// Shared command set for "IP address + DHCP pool + DHCP server + DHCP network on one
/// interface" — used by the LAN step directly and, per entry, by the VLAN step.
enum DhcpServerCommandBuilder {
static func buildCommands(
interfaceName: String,
routerAddress: String,
networkAddress: String,
poolRangeStart: String,
poolRangeEnd: String,
leaseTimeHours: Int,
dnsServers: String,
context: String
) -> [RouterOSCommand] {
let poolName = "dhcp_pool_\(interfaceName)"
let serverName = "dhcp_\(interfaceName)"
let routerIP = routerAddress.components(separatedBy: "/").first ?? routerAddress
return [
RouterOSCommand(
cliPath: "/ip address add",
restPath: "ip/address",
arguments: ["address": routerAddress, "interface": interfaceName],
summary: "IP-Adresse \(routerAddress) \(context) setzen"
),
RouterOSCommand(
cliPath: "/ip pool add",
restPath: "ip/pool",
arguments: ["name": poolName, "ranges": "\(poolRangeStart)-\(poolRangeEnd)"],
summary: "Adressbereich \(poolRangeStart)\(poolRangeEnd) \(context) anlegen"
),
RouterOSCommand(
cliPath: "/ip dhcp-server add",
restPath: "ip/dhcp-server",
arguments: [
"name": serverName,
"interface": interfaceName,
"address-pool": poolName,
"lease-time": "\(leaseTimeHours)h",
"disabled": "no"
],
summary: "DHCP-Server \(context) aktivieren"
),
RouterOSCommand(
cliPath: "/ip dhcp-server network add",
restPath: "ip/dhcp-server/network",
arguments: [
"address": networkAddress,
"gateway": routerIP,
"dns-server": dnsServers
],
summary: "DHCP-Netzwerk \(networkAddress) \(context) konfigurieren"
)
]
}
}