From f12a5229a66ecdd30673255e7fa0b7ea71663b93 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Tue, 15 Sep 2015 20:46:28 +0200 Subject: avahi - expose many more config options in GUI --- config/avahi/avahi.inc | 118 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 27 deletions(-) (limited to 'config/avahi') diff --git a/config/avahi/avahi.inc b/config/avahi/avahi.inc index 4c824e71..ba89676f 100644 --- a/config/avahi/avahi.inc +++ b/config/avahi/avahi.inc @@ -63,23 +63,36 @@ function avahi_deinstall() { } function avahi_write_config() { - global $config; + global $config, $avahi_config; conf_mount_rw(); // Pull some various values out of config.xml + if (isset($config['installedpackages']['avahi']['config'][0])) { + $avahi_config = $config['installedpackages']['avahi']['config'][0]; + } + // Server Options $hostname = $config['system']['hostname']; $domain = $config['system']['domain']; - $enable = $config['installedpackages']['avahi']['config'][0]['enable']; - $browsedomains = $config['installedpackages']['avahi']['config'][0]['browsedomains']; - $denyif = $config['installedpackages']['avahi']['config'][0]['denyinterfaces']; - $useipv4 = ($config['installedpackages']['avahi']['config'][0]['disable_ipv4']) ? "no" : "yes"; - $useipv6 = ($config['installedpackages']['avahi']['config'][0]['disable_ipv6']) ? "no" : "yes"; - $usedbus = ($config['installedpackages']['avahi']['config'][0]['disable_dbus']) ? "no" : "yes"; - - // No supplied domains? Use the defaults. - if (!$browsedomains) { - $browsedomains = "local, 0pointer.de, zeroconf.org"; - } + $enable = $avahi_config['enable']; + $browsedomains = $avahi_config['browsedomains'] ?: "local"; + $denyif = $avahi_config['denyinterfaces']; + $useipv4 = ($avahi_config['enable_ipv4']) ? "yes" : "no"; + $useipv6 = ($avahi_config['enable_ipv6']) ? "yes" : "no"; + $usedbus = ($avahi_config['disable_dbus']) ? "no" : "yes"; + // Wide Area + $widearea = ($avahi_config['enable_wide_area']) ? "yes" : "no"; + // Publishing Options + $publish = ($avahi_config['disable_publishing']) ? "no" : "yes"; + $userpublish = ($avahi_config['disable_user_service_publishing']) ? "no" : "yes"; + $addresspublish = ($avahi_config['publish_addresses']) ? "yes" : "no"; + $cookie = ($avahi_config['add_service_cookie']) ? "yes" : "no"; + $hinfopublish = ($avahi_config['publish_hinfo']) ? "yes" : "no"; + $wspublish = ($avahi_config['publish_workstation']) ? "yes" : "no"; + $aaaaonv4 = ($avahi_config['publish_aaaa_on_ipv4']) ? "yes" : "no"; + $aonv6 = ($avahi_config['publish_a_on_ipv6']) ? "yes" : "no"; + // Reflector Options + $reflect = ($avahi_config['enable_reflector']) ? "yes" : "no"; + $reflectipv = ($avahi_config['reflect_ipv']) ? "yes" : "no"; // Never pass along WAN. Bad. $denyinterfaces = $config['interfaces']['wan']['if']; @@ -94,6 +107,15 @@ function avahi_write_config() { } } } + + // Process DNS servers and omit localhost if present in /etc/resolv.conf + $publishdns = ''; + $dns = implode(" ", get_dns_servers()); + $dns = trim(str_replace('127.0.0.1', '', $dns)); + $dns = str_replace(' ', ', ', $dns); + if ($dns) { + $publishdns = "publish-dns-servers={$dns}"; + } // Construct the avahi configuration $avahiconfig = << 0 ) { + write_config("[avahi] Upgraded old package configuration."); + } +} + +function avahi_validate_input($post, &$input_errors) { + if (($post['enable_ipv4'] != "on" ) && ($post['enable_ipv6'] != "on" )) { + $input_errors[] = gettext("You cannot disable both IPv4 and IPv6!"); + } + if (($post['enable_ipv4'] != "on" ) && ($post['publish_aaaa_on_ipv4'] == "on" )) { + $input_errors[] = gettext("'Publish AAAA records on IPv4' makes no sense with IPv4 disabled."); + } + if (($post['enable_ipv6'] != "on" ) && ($post['publish_a_on_ipv6'] == "on" )) { + $input_errors[] = gettext("'Publish A records on IPv6' makes no sense with IPv6 disabled."); + } +} + ?> -- cgit v1.2.3