mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
system: simplify previous
We can add multiple ports (like GUI 80, 443) and still look up only one of them.
This commit is contained in:
parent
4cd1b72d4d
commit
28fa6a6868
@ -353,7 +353,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = [])
|
||||
$dnslist_tmp = $dhcpv6ifconf['dnsserver'];
|
||||
} elseif (!isset($dhcpv6ifconf['rasamednsasdhcp6']) && !empty($dhcpv6ifconf['radnsserver'][0])) {
|
||||
$dnslist_tmp = $dhcpv6ifconf['radnsserver'];
|
||||
} elseif (!empty(service_by_name('*', ['ports' => ['53']]))) {
|
||||
} elseif (!empty(service_by_filter(['ports' => '53']))) {
|
||||
if (is_ipaddrv6($ifcfgipv6)) {
|
||||
$dnslist_tmp[] = $ifcfgipv6;
|
||||
} else {
|
||||
@ -448,7 +448,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = [])
|
||||
$networkv6 = '::/64';
|
||||
}
|
||||
|
||||
if (!empty(service_by_name('*', ['ports' => ['53']]))) {
|
||||
if (!empty(service_by_filter(['ports' => '53']))) {
|
||||
if (is_ipaddrv6($ifcfgipv6)) {
|
||||
$dnslist[] = $ifcfgipv6;
|
||||
} else {
|
||||
@ -743,7 +743,7 @@ EOPP;
|
||||
if (!empty($newzone['domain-name'])) {
|
||||
$newzone['dns-servers'] = $dhcpifconf['dnsserver'];
|
||||
}
|
||||
} elseif (!empty(service_by_name('*', ['ports' => ['53']]))) {
|
||||
} elseif (!empty(service_by_filter(['ports' => '53']))) {
|
||||
$dnscfg .= " option domain-name-servers {$ifcfgip};";
|
||||
if (!empty($newzone['domain-name'])) {
|
||||
$newzone['dns-servers'] = [$ifcfgip];
|
||||
@ -1459,7 +1459,7 @@ EOD;
|
||||
|
||||
if (isset($dhcpv6ifconf['dnsserver'][0])) {
|
||||
$dnscfgv6 .= " option dhcp6.name-servers " . join(",", $dhcpv6ifconf['dnsserver']) . ";";
|
||||
} elseif (!empty(service_by_name('*', ['ports' => ['53']]))) {
|
||||
} elseif (!empty(service_by_filter(['ports' => '53']))) {
|
||||
$dnscfgv6 .= " option dhcp6.name-servers {$ifcfgipv6};";
|
||||
} elseif (!empty($dns_arrv6)) {
|
||||
$dnscfgv6 .= " option dhcp6.name-servers " . join(",", $dns_arrv6) . ";";
|
||||
|
||||
@ -202,7 +202,7 @@ function system_resolvconf_generate($verbose = false)
|
||||
$search[] = $syscfg['dnssearchdomain'];
|
||||
}
|
||||
|
||||
if (!isset($syscfg['dnslocalhost']) && !empty(service_by_name('*', ['ports' => ['53']]))) {
|
||||
if (!isset($syscfg['dnslocalhost']) && !empty(service_by_filter(['ports' => '53']))) {
|
||||
$resolvconf .= "nameserver 127.0.0.1\n";
|
||||
}
|
||||
|
||||
|
||||
@ -100,6 +100,11 @@ function is_process_running($process)
|
||||
return (intval($retval) == 0);
|
||||
}
|
||||
|
||||
function service_by_filter($filter = [])
|
||||
{
|
||||
return service_by_name('*', $filter);
|
||||
}
|
||||
|
||||
function service_by_name($name, $filter = [])
|
||||
{
|
||||
$services = plugins_services();
|
||||
@ -114,7 +119,10 @@ function service_by_name($name, $filter = [])
|
||||
$filter['name'] = $name;
|
||||
}
|
||||
foreach ($filter as $key => $value) {
|
||||
if (isset($service[$key]) && $service[$key] == $value) {
|
||||
if (
|
||||
isset($service[$key]) && ($service[$key] == $value ||
|
||||
(is_array($service[$key]) && in_array($value, $service[$key])))
|
||||
) {
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
|
||||
$dnsmasq_port = empty($pconfig['port']) ? "53" : $pconfig['port'];
|
||||
$port_conflict = service_by_name('*', ['ports' => [$dnsmasq_port]]);
|
||||
if (!empty($pconfig['enable']) && !empty($port_conflict)) {
|
||||
$port_conflict = service_by_filter(['ports' => $dnsmasq_port]);
|
||||
if (!empty($pconfig['enable']) && !empty($port_conflict) && $port_conflict['name'] != 'dnsmasq') {
|
||||
$input_errors[] = sprintf(gettext('%s is currently using this port.'), $port_conflict['description']);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user