dnsmasq: look up port conflict via service framework

This commit is contained in:
Franco Fichtner 2023-03-24 13:32:21 +01:00
parent 68f781f430
commit 4cd1b72d4d

View File

@ -82,12 +82,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($pconfig['local_ttl']) && $pconfig['local_ttl'] !== '' && !is_numericint($pconfig['local_ttl'])) {
$input_errors[] = gettext("You must specify a valid TTL for local DNS");
}
$unbound_mdl = new \OPNsense\Unbound\Unbound();
$unbound_enabled = (string)$unbound_mdl->general->enabled;
$unbound_port = (string)$unbound_mdl->general->port;
$dnsmasq_port = empty($pconfig['port']) ? "53" : $pconfig['port'];
if (!empty($pconfig['enable']) && !empty($unbound_enabled) && $dnsmasq_port == $unbound_port) {
$input_errors[] = gettext('Unbound is still active on the same port. Disable it before enabling Dnsmasq.');
$port_conflict = service_by_name('*', ['ports' => [$dnsmasq_port]]);
if (!empty($pconfig['enable']) && !empty($port_conflict)) {
$input_errors[] = sprintf(gettext('%s is currently using this port.'), $port_conflict['description']);
}
if (count($input_errors) == 0) {