dnsmasq: second part of slurp rework

Align this code with Unbound, slowly ridding ourselves of
get_possible_listen_ips() in the process as well.

PR: https://twitter.com/wget42/status/1009886764155260928
This commit is contained in:
Franco Fichtner 2018-07-02 16:19:58 +00:00
parent f344e9d447
commit ad6c7384e4
2 changed files with 11 additions and 20 deletions

View File

@ -118,18 +118,14 @@ function dnsmasq_configure_do($verbose = false)
}
if (isset($config['dnsmasq']['interface'])) {
$addresses = array();
$addresses = array('127.0.0.1', '::1');
foreach (explode(',', $config['dnsmasq']['interface']) as $interface) {
if (is_ipaddrv4($interface)) {
$addresses[] = $interface;
} elseif (is_ipaddrv6($interface)) {
/* no support for link-local address with scope specified */
$addresses[] = explode("%", $interface)[0];
} else {
foreach (legacy_getall_interface_addresses(get_real_interface($$interface)) as $tmpaddr) {
$tmpaddr = explode('/', $tmpaddr)[0];
$tmpaddr = explode('%', $tmpaddr)[0];
foreach (legacy_getall_interface_addresses(get_real_interface($interface)) as $tmpaddr) {
$tmpaddr = explode('/', $tmpaddr)[0];
/* no support for link-local address with scope specified */
$tmpaddr = explode('%', $tmpaddr)[0];
if (!empty($tmpaddr)) {
$addresses[] = $tmpaddr;
}
}

View File

@ -349,17 +349,12 @@ $( document ).ready(function() {
<tr>
<td><a id="help_for_interfaces" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Interfaces"); ?></td>
<td>
<select id="interface" name="interface[]" multiple="multiple" class="selectpicker">
<option value="" <?=empty($pconfig['interface'][0]) ? 'selected="selected"' : ""; ?>>
<?=gettext("All");?>
<select id="interface" name="interface[]" multiple="multiple" class="selectpicker" title="<?= html_safe(gettext('All')) ?>">
<?php foreach (get_configured_interface_with_descr() as $iface => $ifacename): ?>
<option value="<?= html_safe($iface) ?>" <?=in_array($iface, $pconfig['interface']) ? 'selected="selected"' : "" ?>>
<?= html_safe($ifacename) ?>
</option>
<?php
foreach (get_possible_listen_ips(true) as $laddr):?>
<option value="<?=$laddr['value'];?>" <?=in_array($laddr['value'], $pconfig['interface']) ? 'selected="selected"' : "";?>>
<?=htmlspecialchars($laddr['name']);?>
</option>
<?php
endforeach; ?>
<?php endforeach ?>
</select>
<div class="hidden" data-for="help_for_interfaces">
<?=gettext("Interface IPs used by the DNS Forwarder for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. The default behavior is to respond to queries on every available IPv4 and IPv6 address.");?>