This commit is contained in:
2025-05-27 18:06:36 +02:00
parent 0b3bd9108c
commit bf81566b88
6 changed files with 216 additions and 88 deletions

22
load-ranges.php Normal file
View File

@ -0,0 +1,22 @@
<?php
require_once "common.php";
require_once "load-conf.php";
$ranges = [];
if (isset($conf["conf-file"]) && file_exists($conf["conf-file"])) {
foreach(file($conf["conf-file"]) as $line) {
if (preg_match(
"/^dhcp-range=(?:(?:tag|set):(?<tag>$namePtn),)?(?<start_addr>$ipPtn),(?:(?<end_addr>$ipPtn)|$modesPtn)(?:,(?<netmask>$ipPtn)(?:,$ipPtn)?)?(?:,(?<lease_time>$timePtn|infinite))?$commentPtn$/",
$line, $range, PREG_UNMATCHED_AS_NULL
)) {
if (!isset($range["tag"])) $range["tag"] = "default";
if (!isset($ranges[$range["tag"]])) $ranges[$range["tag"]] = [];
$ranges[$range["tag"]]["dhcp-range"] = [
"start-addr" => $range["start_addr"],
"end-addr" => $range["end_addr"],
"netmask" => $range["netmask"],
"lease_time" => $range["lease_time"],
];
}
}
}