Commit 2e3cf91c authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

cleanup in services_dnsmasq_configure, remove duplicate code, for...

cleanup in services_dnsmasq_configure, remove duplicate code, for https://github.com/opnsense/core/issues/1182

(cherry picked from commit 52c78955)
parent 1ad859e8
...@@ -1883,51 +1883,30 @@ function services_dnsmasq_configure($dhcp_reload = true) ...@@ -1883,51 +1883,30 @@ function services_dnsmasq_configure($dhcp_reload = true)
$args .= " --port={$config['dnsmasq']['port']} "; $args .= " --port={$config['dnsmasq']['port']} ";
} }
$listen_addresses = "";
if (isset($config['dnsmasq']['interface'])) { if (isset($config['dnsmasq']['interface'])) {
$interfaces = explode(",", $config['dnsmasq']['interface']); $addresses = array();
foreach ($interfaces as $interface) { foreach (explode(",", $config['dnsmasq']['interface']) as $interface) {
if (is_ipaddrv4($interface)) { if (is_ipaddrv4($interface)) {
$listen_addresses .= " --listen-address={$interface} "; $addresses[] = $interface;
} elseif (is_ipaddrv6($interface)) { } elseif (is_ipaddrv6($interface)) {
/* // Since dnsmasq does not support link-local address with scope specified. strip address.
* XXX: Since dnsmasq does not support link-local address $addresses[] = explode("%", $interface)[0];
* with scope specified. These checks are being done.
*/
if (is_linklocal($interface) && strstr($interface, "%")) {
$tmpaddrll6 = explode("%", $interface);
$listen_addresses .= " --listen-address={$tmpaddrll6[0]} ";
} else {
$listen_addresses .= " --listen-address={$interface} ";
}
} else { } else {
$if = get_real_interface($interface); $intf_ipv4 = get_interface_ip($interface);
if (does_interface_exist($if)) { $intf_ipv6 = get_interface_ipv6($interface);
$laddr = find_interface_ip($if); if (!empty($intf_ipv4)) {
if (is_ipaddrv4($laddr)) { $addresses[] = $intf_ipv4;
$listen_addresses .= " --listen-address={$laddr} "; }
} if (!empty($intf_ipv6)) {
$laddr6 = find_interface_ipv6($if); $addresses[] = explode("%", $intf_ipv6)[0];
if (is_ipaddrv6($laddr6) && !isset($config['dnsmasq']['strictbind'])) {
/*
* XXX: Since dnsmasq does not support link-local address
* with scope specified. These checks are being done.
*/
if (is_linklocal($laddr6) && strstr($laddr6, "%")) {
$tmpaddrll6 = explode("%", $laddr6);
$listen_addresses .= " --listen-address={$tmpaddrll6[0]} ";
} else {
$listen_addresses .= " --listen-address={$laddr6} ";
}
}
} }
} }
} }
if (!empty($listen_addresses)) { foreach ($addresses as $address) {
$args .= " {$listen_addresses} "; $args .= " --listen-address={$address} ";
if (isset($config['dnsmasq']['strictbind'])) { }
$args .= " --bind-interfaces "; if (!empty($addresses) && isset($config['dnsmasq']['strictbind'])) {
} $args .= " --bind-interfaces ";
} }
} }
......
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