From 4cd1b72d4d373f75aaba37964b0224d83d4c9ff7 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 24 Mar 2023 13:32:21 +0100 Subject: [PATCH] dnsmasq: look up port conflict via service framework --- src/www/services_dnsmasq.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/www/services_dnsmasq.php b/src/www/services_dnsmasq.php index 827859795..f5a728fe3 100644 --- a/src/www/services_dnsmasq.php +++ b/src/www/services_dnsmasq.php @@ -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) {