Merge pull request #506 from glaszig/feature/dhcp-upstream-server

[WIP] added ui to manage upstream dns servers
This commit is contained in:
Bill Zimmerman
2020-03-04 23:07:35 +01:00
committed by GitHub
5 changed files with 186 additions and 19 deletions

View File

@@ -59,6 +59,13 @@ function DisplayDHCPConfig()
}
}
if ($_POST['no-resolv'] == "1") {
$config .= "no-resolv".PHP_EOL;
}
foreach ($_POST['server'] as $server) {
$config .= "server=$server".PHP_EOL;
}
if ($_POST['DNS1']) {
$config .= "dhcp-option=6," . $_POST['DNS1'];
if ($_POST['DNS2']) {
@@ -126,6 +133,8 @@ function DisplayDHCPConfig()
$dhcpHost = $conf["dhcp-host"];
$dhcpHost = empty($dhcpHost) ? [] : $dhcpHost;
$dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ];
$upstreamServers = is_array($conf['server']) ? $conf['server'] : [ $conf['server'] ];
$upstreamServers = array_filter($upstreamServers);
$DNS1 = '';
$DNS2 = '';
@@ -173,6 +182,7 @@ function DisplayDHCPConfig()
"RangeEnd",
"DNS1",
"DNS2",
"upstreamServers",
"arrRangeLeaseTime",
"mselected",
"hselected",

View File

@@ -346,3 +346,27 @@ function mb_escapeshellarg($arg)
return "\"$escaped_arg\"";
}
function dnsServers()
{
$data = json_decode(file_get_contents("./config/dns-servers.json"));
return (array) $data;
}
function optionsForSelect($options)
{
$html = "";
foreach ($options as $key => $value) {
// optgroup
if (is_array($value)) {
$html .= "<optgroup label=\"$key\">";
$html .= optionsForSelect($value);
$html .= "</optgroup>";
}
// option
else {
$key = is_int($key) ? $value : $key;
$html .= "<option value=\"$value\">$key</option>";
}
}
return $html;
}