diff --git a/src/etc/inc/plugins.inc.d/dnsmasq.inc b/src/etc/inc/plugins.inc.d/dnsmasq.inc index c65990d33..fb76bb307 100644 --- a/src/etc/inc/plugins.inc.d/dnsmasq.inc +++ b/src/etc/inc/plugins.inc.d/dnsmasq.inc @@ -186,9 +186,24 @@ function dnsmasq_configure_do($verbose = false) $args .= ' --no-hosts '; } - $args .= ' --dns-forward-max=5000 '; - $args .= ' --cache-size=10000 '; - $args .= ' --local-ttl=1 '; + if (isset($config['dnsmasq']['dns_forward_max']) && is_numericint($config['dnsmasq']['dns_forward_max'])) { + $args .= " --dns-forward-max={$config['dnsmasq']['dns_forward_max']} "; + } else { + $args .= ' --dns-forward-max=5000 '; + } + + if (isset($config['dnsmasq']['cache_size']) && is_numericint($config['dnsmasq']['cache_size'])) { + $args .= " --cache-size={$config['dnsmasq']['cache_size']} "; + } else { + $args .= ' --cache-size=10000 '; + } + + if (isset($config['dnsmasq']['local_ttl']) && is_numericint($config['dnsmasq']['local_ttl'])) { + $args .= " --local-ttl={$config['dnsmasq']['local_ttl']} "; + } else { + $args .= ' --local-ttl=1 '; + } + $args .= ' --conf-dir=/usr/local/etc/dnsmasq.conf.d,\*.conf '; _dnsmasq_add_host_entries(); diff --git a/src/www/services_dnsmasq.php b/src/www/services_dnsmasq.php index ece40c921..a2e152858 100644 --- a/src/www/services_dnsmasq.php +++ b/src/www/services_dnsmasq.php @@ -52,6 +52,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['no_hosts'] = isset($a_dnsmasq['no_hosts']); // simple text types $pconfig['port'] = !empty($a_dnsmasq['port']) ? $a_dnsmasq['port'] : ""; + $pconfig['dns_forward_max'] = !empty($a_dnsmasq['dns_forward_max']) ? $a_dnsmasq['dns_forward_max'] : ""; + $pconfig['cache_size'] = !empty($a_dnsmasq['cache_size']) ? $a_dnsmasq['cache_size'] : ""; + $pconfig['local_ttl'] = !empty($a_dnsmasq['local_ttl']) ? $a_dnsmasq['local_ttl'] : ""; // arrays $pconfig['interface'] = !empty($a_dnsmasq['interface']) ? explode(",", $a_dnsmasq['interface']) : array(); @@ -66,6 +69,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['port']) && !is_port($pconfig['port'])) { $input_errors[] = gettext("You must specify a valid port number"); } + if (!empty($pconfig['dns_forward_max']) && !is_numericint($pconfig['dns_forward_max'])) { + $input_errors[] = gettext("You must specify a valid maximum number of DNS queries"); + } + if (!empty($pconfig['cache_size']) && !is_numericint($pconfig['cache_size'])) { + $input_errors[] = gettext("You must specify a valid cache size"); + } + if (!empty($pconfig['local_ttl']) && !is_numericint($pconfig['local_ttl'])) { + $input_errors[] = gettext("You must specify a valid TTL for local DNS"); + } $unbound_port = empty($config['unbound']['port']) ? "53" : $config['unbound']['port']; $dnsmasq_port = empty($pconfig['port']) ? "53" : $pconfig['port']; if (!empty($pconfig['enable']) && isset($config['unbound']['enable']) && $dnsmasq_port == $unbound_port) { @@ -100,6 +112,21 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } elseif (isset($a_dnsmasq['port'])) { unset($a_dnsmasq['port']); } + if (!empty($pconfig['dns_forward_max'])) { + $a_dnsmasq['dns_forward_max'] = $pconfig['dns_forward_max']; + } elseif (isset($a_dnsmasq['dns_forward_max'])) { + unset($a_dnsmasq['dns_forward_max']); + } + if (!empty($pconfig['cache_size'])) { + $a_dnsmasq['cache_size'] = $pconfig['cache_size']; + } elseif (isset($a_dnsmasq['cache_size'])) { + unset($a_dnsmasq['cache_size']); + } + if (!empty($pconfig['local_ttl'])) { + $a_dnsmasq['local_ttl'] = $pconfig['local_ttl']; + } elseif (isset($a_dnsmasq['local_ttl'])) { + unset($a_dnsmasq['local_ttl']); + } write_config(); system_resolvconf_generate(); dnsmasq_configure_do(); @@ -371,6 +398,33 @@ $( document ).ready(function() { + + + + /> + + + + + + + /> + + + + + + + /> + + +