Commit 4a435261 authored by Franco Fichtner's avatar Franco Fichtner

dns: consolidate previous, remove service names hack... #1491

... that was written at a time when either Unbound or Dnsmasq
could run, but nowadays both can run in tandem which "breaks"
the service widget on the log page.  The log page now belongs
to the Unbound service.
parent 2e19f4ec
...@@ -1720,32 +1720,21 @@ function services_get() ...@@ -1720,32 +1720,21 @@ function services_get()
return $services; return $services;
} }
function find_service_by_name($names, $filter = array()) function find_service_by_name($name, $filter = array())
{ {
if (!is_array($names)) {
$names = array($names);
}
$services = services_get(); $services = services_get();
foreach ($services as $service) { foreach ($services as $service) {
foreach ($names as $name) { if ($service['name'] != $name) {
if ($service['name'] != $name) { continue;
continue; }
} if (!count($filter)) {
if (!count($filter)) { /* force match if filter wasn't set (standard behaviour) */
/* force match if filter wasn't set (standard behaviour) */ $filter['name'] = $name;
$filter['name'] = $name; }
} foreach ($filter as $key => $value) {
foreach ($filter as $key => $value) { if (isset($service[$key]) && $service[$key] == $value) {
if (isset($service[$key]) && $service[$key] == $value) { return $service;
/*
* First match wins, $names is only used
* to probe similar services that exclude
* each other.
*/
return $service;
}
} }
} }
} }
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</Leases> </Leases>
</DHCPv6> </DHCPv6>
<DNSTools VisibleName="DNS Tools" cssClass="fa fa-tags fa-fw"> <DNSTools VisibleName="DNS Tools" cssClass="fa fa-tags fa-fw">
<DNSFilter VisibleName="OpenDNS" url="/services_opendns.php"/> <OpenDNS VisibleName="OpenDNS" url="/services_opendns.php"/>
</DNSTools> </DNSTools>
<Diagnostics order="900" cssClass="fa fa-medkit fa-fw" url="/status_services.php"> <Diagnostics order="900" cssClass="fa fa-medkit fa-fw" url="/status_services.php">
<All url="/status_services.php?*" visibility="hidden"/> <All url="/status_services.php?*" visibility="hidden"/>
......
<menu> <menu>
<Services> <Services>
<DNSForwarder VisibleName="Dnsmasq DNS" url="/services_dnsmasq.php" cssClass="fa fa-tags fa-fw"> <Dnsmasq VisibleName="Dnsmasq DNS" url="/services_dnsmasq.php" cssClass="fa fa-tags fa-fw">
<Hosts url="/services_dnsmasq_edit.php*" visibility="hidden"/> <Hosts url="/services_dnsmasq_edit.php*" visibility="hidden"/>
<Domains url="/services_dnsmasq_domainoverride_edit.php*" visibility="hidden"/> <Domains url="/services_dnsmasq_domainoverride_edit.php*" visibility="hidden"/>
</DNSForwarder> </Dnsmasq>
</Services> </Services>
</menu> </menu>
<menu> <menu>
<Services> <Services>
<DNSResolver VisibleName="Unbound DNS" cssClass="fa fa-tags fa-fw"> <Unbound VisibleName="Unbound DNS" cssClass="fa fa-tags fa-fw">
<General order="10" url="/services_unbound.php"/> <General order="10" url="/services_unbound.php"/>
<Overrides order="20" url="/services_unbound_overrides.php"> <Overrides order="20" url="/services_unbound_overrides.php">
<Hosts url="/services_unbound_host_edit.php*" visibility="hidden"/> <Hosts url="/services_unbound_host_edit.php*" visibility="hidden"/>
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
<All url="/services_unbound_acls.php*" visibility="hidden"/> <All url="/services_unbound_acls.php*" visibility="hidden"/>
</ACL> </ACL>
<LogFile VisibleName="Log File" order="50" url="/diag_logs_resolver.php"/> <LogFile VisibleName="Log File" order="50" url="/diag_logs_resolver.php"/>
</DNSResolver> </Unbound>
</Services> </Services>
</menu> </menu>
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
$logfile = '/var/log/resolver.log'; $logfile = '/var/log/resolver.log';
$logclog = true; $logclog = true;
$service_hook = array('dnsmasq', 'unbound'); $service_hook = 'unbound';
require_once 'diag_logs_template.inc'; require_once 'diag_logs_template.inc';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment