<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
        <copyright>
        <![CDATA[
/* $Id$ */
/* ========================================================================== */
/*
    tinydns_domains.xml
    part of pfSense (http://www.pfSense.com)
    Copyright (C) 2008 Scott Ullrich
    All rights reserved.
                                                                              */
/* ========================================================================== */
/*
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

     1. Redistributions of source code must retain the above copyright notice,
        this list of conditions and the following disclaimer.

     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
                                                                              */
/* ========================================================================== */
        ]]>
	</copyright>
    <description>Describe your package here</description>
    <requirements>Describe your package requirements here</requirements>
    <faq>Currently there are no FAQ items provided.</faq>
	<name>tinydnsdomains</name>
	<version>none</version>
	<title>TinyDNS: Domains</title>
	<include_file>/usr/local/pkg/tinydns.inc</include_file>
	<tabs>
		<tab>
			<text>Settings</text>
			<url>/pkg_edit.php?xml=tinydns.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>Add/Edit Record</text>
			<url>/tinydns_filter.php</url>
			<active/>
		</tab>
		<tab>
			<text>Failover Status</text>
			<url>/tinydns_status.php</url>
		</tab>
		<tab>
			<text>Logs</text>
			<url>/tinydns_view_logs.php</url>
		</tab>
		<tab>
			<text>Sync</text>
			<url>/pkg_edit.php?xml=tinydns_sync.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>New domain wizard</text>
			<url>/wizard.php?xml=new_zone_wizard.xml</url>
		</tab>			
	</tabs>
	<configpath>installedpackages->package->tinydnsdomains</configpath>
	<adddeleteeditpagefields>
		<columnitem>
			<fielddescr>Record Name</fielddescr>
			<fieldname>hostname</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>Record Type</fielddescr>
			<fieldname>recordtype</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>rDNS</fielddescr>
			<fieldname>rdns</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>Record Data</fielddescr>
			<fieldname>ipaddress</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>TTL</fielddescr>
			<fieldname>ttl</fieldname>
		</columnitem>
	</adddeleteeditpagefields>
	<fields>
		<field>
			<type>listtopic</type>
			<name>General</name>
			<fieldname>temp</fieldname>			
		</field>		
		<field>
			<fielddescr>Record Name (Hostname or FQDN.  E.g. www.exampledomain.com)</fielddescr>
			<fieldname>hostname</fieldname>
			<description>The DNS server will supply Records for the Fully Qualified Domain Name that is entered</description>
			<type>input</type>
			<size>35</size>
			<required/>
		</field>
		<field>
			<fielddescr>Record Type</fielddescr>
			<fieldname>recordtype</fieldname>
			<description>Supported Record types: A, PTR, MX, NS, SOA, TXT, CNAME, raw  ("raw" allows direct entry of a complete TinyDNS record in the FQDN field below)</description>
			<type>select</type>
			<size>1</size>
			<required/>
			<options>
			    <option><name></name><value></value></option>
			    <option><name>A</name><value>A</value></option>
			    <option><name>MX</name><value>MX</value></option>
			    <option><name>NS</name><value>NS</value></option>
			    <option><name>SOA</name><value>SOA</value></option>
			    <option><name>PTR</name><value>PTR</value></option>
			    <option><name>CNAME</name><value>CNAME</value></option>
			    <option><name>TXT</name><value>TXT</value></option>
			    <option><name>raw</name><value>raw</value></option>
			</options>
		</field>
		<field>
			<fielddescr>Record Data (FQDN, IP Address, or "raw" TinyDNS record)</fielddescr>
			<fieldname>ipaddress</fieldname>
			<description>Use IP Address for A Records - FQDN or Hostname for SOA, PTR, CNAME Records - NS Records use colon-separated IP and FQDN, e.g. 1.2.3.4:mydomain.com</description>
			<type>input</type>
			<size>80</size>
			<required/>
		</field>
		<field>
			<fielddescr>MX priority (only used for MX records)</fielddescr>
			<fieldname>dist</fieldname>
			<type>input</type>
			<size>4</size>
		</field>				
		<field>
			<fielddescr>DNS record time to live (in seconds)</fielddescr>
			<fieldname>ttl</fieldname>
			<type>input</type>
			<size>35</size>
		</field>				
		<field>
			<type>listtopic</type>
			<name>Reverse lookup</name>
			<fieldname>temp</fieldname>						
		</field>
		<field>
		 	<fielddescr>Automatic PTR entry</fielddescr>
			<fieldname>rdns</fieldname>
			<description>Create a reverse DNS (PTR) entry for this A Record?</description>
			<type>checkbox</type>
		</field>		
		<field>
			<type>listtopic</type>
			<name>Failover</name>
			<fieldname>temp</fieldname>						
		</field>
		<field>
			<fielddescr>IP to ping to ensure service is up</fielddescr>
			<fieldname>monitorip</fieldname>
			<type>input</type>
			<size>35</size>
		</field>
		<field>
			<fielddescr>Time in minutes before DNS switches to backup host</fielddescr>
			<fieldname>threshhold</fieldname>
			<type>input</type>
			<size>35</size>
		</field>
		<field>
			<fielddescr>none</fielddescr>
			<fieldname>none</fieldname>
		    <type>rowhelper</type>
		    <rowhelper>
				<rowhelperfield>
				    <fielddescr>Failover IP</fielddescr>
				    <fieldname>failoverip</fieldname>
				    <description>Failover IP when host is not responding to ICMP/PING traffic</description>
				    <type>input</type>
				    <size>25</size>
				</rowhelperfield>
				<rowhelperfield>
				    <fielddescr>Load balance</fielddescr>
				    <fieldname>loadbalance</fieldname>
				    <description>Adds this member to active group when host is alive.</description>
				    <type>checkbox</type>
				</rowhelperfield>
				<rowhelperfield>
				    <fielddescr>Ping threshold</fielddescr>
				    <fieldname>pingthreshold</fieldname>
				    <description>When the MS time is surpassed, item will failover to next host</description>
				    <type>input</type>
				    <size>7</size>
				</rowhelperfield>
				<rowhelperfield>
				    <fielddescr>Wan ping threshold</fielddescr>
				    <fieldname>wanpingthreshold</fieldname>
				    <description>When the WAN MS ping time is surpassed, item will failover to next host</description>
				    <type>input</type>
				    <size>7</size>
				</rowhelperfield>
				<rowhelperfield>
				    <fielddescr>IP to ping to ensure service is up</fielddescr>
				    <fieldname>monitorip</fieldname>
				    <description>When the WAN MS ping time is surpassed, item will failover to next host</description>
				    <type>input</type>
				    <size>15</size>
				</rowhelperfield>
		    </rowhelper>
		</field>
	</fields>
	<custom_delete_php_command>
		$dnssync = true;		
		tinydns_create_zone_file();
		tinydns_setup_ping_items();
		tinydns_sync_on_changes();
	</custom_delete_php_command>
	<custom_php_validation_command>
		if(function_exists("tinydns_cleanup_addedit_form_record"))
			tinydns_cleanup_addedit_form_record();
		else {
			require_once("/usr/local/pkg/tinydns.inc");
		}
	</custom_php_validation_command>
	<custom_add_php_command>
		$dnssync = true;
		log_error("Begin tinydns add");		
		tinydns_create_zone_file();
		log_error("Zone file done.");
		tinydns_setup_ping_items();
		log_error("Ping items done.");
		tinydns_sync_on_changes();
		log_error("Sync items done.");
	</custom_add_php_command>
	<custom_php_resync_config_command>
		if(!$dnssync) {
			log_error("Begin tinydns resync");
			tinydns_create_zone_file();
			log_error("Zone file done.");
			tinydns_setup_ping_items();
			log_error("Ping items done.");
			tinydns_sync_on_changes();
			log_error("Sync items done.");
		} else {
			tinydns_create_zone_file();
			tinydns_setup_ping_items();
		}
	</custom_php_resync_config_command>
	<custom_php_command_before_form>	
		unset($_POST['temp']);
	</custom_php_command_before_form>
</packagegui>