From 56a87b19c08f77638442d792587d58e2da509f6c Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Wed, 29 Jan 2014 17:07:13 +0200 Subject: Add additional functionality for stats and preconfigure variables --- etc/inc/unbound.inc | 194 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 151 insertions(+), 43 deletions(-) diff --git a/etc/inc/unbound.inc b/etc/inc/unbound.inc index 0d02228..8fcf7b0 100644 --- a/etc/inc/unbound.inc +++ b/etc/inc/unbound.inc @@ -37,19 +37,6 @@ require_once("config.inc"); require_once("functions.inc"); -function unbound_configure() { - global $config; - - if (is_array($config['captiveportal'])) { - foreach ($config['captiveportal'] as $cpkey => $cp) { - $cpzone = $cpkey; - $cpzoneid = $cp['zoneid']; - captiveportal_configure_zone($cp); - } - } else - mwexec("/sbin/sysctl net.link.ether.ipfw=0"); -} - /* Optimize Unbound for environment */ function unbound_optimization() { global $config; @@ -121,7 +108,7 @@ function unbound_generate_config() { // Setup DNSSEC support if (isset($config['unbound']['dnssec_status'])) { $module_config = "validator iterator"; - $anchor_file = "auto-trust-anchor-file: /etc/root-trust-anchor"; + $anchor_file = "auto-trust-anchor-file: {$g['unbound_chroot_path']}/root-trust-anchor"; } else $module_config = "iterator"; @@ -161,6 +148,26 @@ EOF; $custom_option .= $ent."\n"; } + // Server configuration variables + $hide_id = ($config['unbound']['hide_id'] == "on") ? "yes" : "no"; + $hide_version = ($config['unbound']['hide_version'] == "on") ? "yes" : "no"; + $harden_glue = ($config['unbound']['harden_glue'] == "on") ? "yes" : "no"; + $harden_dnssec_stripped = ($config['unbound']['harden_dnssec_stripped'] == "on") ? "yes" : "no"; + $prefetch = ($config['unbound']['prefetch'] == "on") ? "yes" : "no"; + $prefetch_key = ($config['unbound']['prefetch_key'] == "on") ? "yes" : "no"; + $outgoing_num_tcp = (!empty($config['unbound']['outgoing_num_tcp'])) ? $config['unbound']['outgoing_num_tcp'] : "10"; + $incoming_num_tcp = (!empty($config['unbound']['incoming_num_tcp'])) ? $config['unbound']['incoming_num_tcp'] : "10"; + $edns_buffer_size = (!empty($config['unbound']['edns_buffer_size'])) ? $config['unbound']['edns_buffer_size'] : "4096"; + $num_queries_per_thread = (!empty($config['unbound']['num_queries_per_thread'])) ? $config['unbound']['num_queries_per_thread'] : "4096"; + $jostle_timeout = (!empty($config['unbound']['jostle_timeout'])) ? $config['unbound']['jostle_timeout'] : "200"; + $cache_max_ttl = (!empty($config['unbound']['cache_max_ttl'])) ? $config['unbound']['cache_max_ttl'] : "86400"; + $cache_min_ttl = (!empty($config['unbound']['cache_min_ttl'])) ? $config['unbound']['cache_min_ttl'] : "0"; + $infra_host_ttl = (!empty($config['unbound']['infra_host_ttl'])) ? $config['unbound']['infra_host_ttl'] : "900"; + $infra_lame_ttl = (!empty($config['unbound']['infra_lame_ttl'])) ? $config['unbound']['infra_lame_ttl'] : "900"; + $infra_cache_numhosts = (!empty($config['unbound']['infra_cache_numhosts'])) ? $config['unbound']['infra_cache_numhosts'] : "10000"; + $unwanted_reply_threshold = (!empty($config['unbound']['unwanted_reply_threshold'])) ? $config['unbound']['unwanted_reply_threshold'] : "0"; + $verbosity = isset($config['unbound']['loglevel']) ? $config['unbound']['loglevel'] : 1; + $unboundconf = << 0) + do_as_unbound_user("load_cache < /var/tmp/unbound_cache"); + } + break; + default: + break; + + } +} + +// Generation of Unbound statistics +function unbound_statistics() { + global $config; + + if ($config['stats'] == "on") { + $stats_interval = $config['unbound']['stats_interval']; + $cumulative_stats = $config['cumulative_stats']; + if ($config['extended_stats'] == "on") + $extended_stats = "yes"; + else + $extended_stats = "no"; + } else { + $stats_interval = "0"; + $cumulative_stats = "no"; + $extended_stats = "no"; + } + /* XXX To do - add RRD graphs */ + $stats = << \ No newline at end of file -- cgit v1.1