<?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[
/* ========================================================================== */
/*
    varnish_backends.xml
    part of pfSense (http://www.pfSense.com)
    Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
    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>varnishbackends</name>
	<version>0.0.2</version>
	<title>Varnish: Backends</title>
	<include_file>/usr/local/pkg/varnish.inc</include_file>
   	<additional_files_needed>
	    <prefix>/usr/local/pkg/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish_lb_directors.xml</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/pkg/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish_settings.xml</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/pkg/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish_custom_vcl.xml</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/pkg/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish.inc</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/pkg/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish_sync.xml</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/www/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnish_view_config.php</item>
	</additional_files_needed>
   	<additional_files_needed>
	    <prefix>/usr/local/www/</prefix>
	    <chmod>0755</chmod>
	    <item>http://www.pfsense.com/packages/config/varnish64/varnishstat.php</item>
	</additional_files_needed>
	<menu>
		<name>Varnish</name>
		<tooltiptext>Varnish</tooltiptext>
		<section>Services</section>
		<configfile>varnish_backends.xml</configfile>
	</menu>
	<service>
		<name>varnish</name>
		<rcfile>varnish.sh</rcfile>
		<executable>varnishd</executable>
		<description>Varnish HTTP accelerator</description>
	</service>
	<tabs>
		<tab>
			<text>Backends</text>
			<url>/pkg.php?xml=varnish_backends.xml</url>
			<active/>
		</tab>
		<tab>
			<text>Settings</text>
			<url>/pkg_edit.php?xml=varnish_settings.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>Custom VCL</text>
			<url>/pkg_edit.php?xml=varnish_custom_vcl.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>LB Directors</text>
			<url>/pkg.php?xml=varnish_lb_directors.xml</url>
		</tab>
		<tab>
			<text>XMLRPC Sync</text>
			<url>/pkg_edit.php?xml=varnish_sync.xml&amp;id=0</url>
		</tab>
		<tab>
			<text>View Configuration</text>
			<url>/varnish_view_config.php</url>
		</tab>
		<tab>
			<text>VarnishSTAT</text>
			<url>/varnishstat.php</url>
		</tab>
	</tabs>
	<adddeleteeditpagefields>
		<columnitem>
			<fielddescr>IPAddress</fielddescr>
			<fieldname>ipaddress</fieldname>
		</columnitem>
		<columnitem>
			<fielddescr>Name</fielddescr>
			<fieldname>backendname</fieldname>
		</columnitem>	
	</adddeleteeditpagefields>
	<fields>
		<field>
			<fielddescr>BackendSettings</fielddescr>
			<fieldname>BackendSettings</fieldname>
			<type>listtopic</type>
			<name>Backend settings</name>
		</field>
		<field>
			<fielddescr>Backend name</fielddescr>
			<fieldname>backendname</fieldname>
			<description>Enter the name of this backend web server.</description>
			<type>input</type>
			<validate>^[a-z0-9.|-]+$</validate>
		</field>
		<field>
			<fielddescr>IPAddress</fielddescr>
			<fieldname>ipaddress</fieldname>
			<description>Enter the IP Address of the backend web server.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Port</fielddescr>
			<fieldname>port</fieldname>
			<description>Enter the TCP/IP port of the webserver.</description>
			<type>input</type>
			<validate>^[0-9]+$</validate>
		</field>
		<field>
			<fielddescr>PerformanceMetrics</fielddescr>
			<fieldname>PerformanceMetrics</fieldname>
			<type>listtopic</type>
			<name>Performance metrics</name>
		</field>		
		<field>
			<fielddescr>First byte timeout</fielddescr>
			<fieldname>first_byte_timeout</fieldname>
			<description> time to wait for the first byte from the backend and .between_bytes_timeout for time to wait between each received byte.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Connect timeout</fielddescr>
			<fieldname>connect_timeout</fieldname>
			<description>The time to wait for a backend connection.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>ProbeInfo</fielddescr>
			<fieldname>ProbeInfo</fieldname>
			<type>listtopic</type>
			<name>Probe settings</name>
		</field>		
		<field>
			<fielddescr>Probe URL</fielddescr>
			<fieldname>probe_url</fieldname>
			<description><![CDATA[Enter the URL that varnish will use to ensure that this backend is healthy.<BR>It can be a url like "/", "/teste.htm" or a request "http://www.pfsense.org/"]]></description>
			<type>input</type>
			<size>40</size> 
		</field>
		<field>
			<fielddescr>Probe Interval</fielddescr>
			<fieldname>probe_interval</fieldname>
			<description>Enter the frequency in seconds that varnish will check the probe url.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Probe Timeout</fielddescr>
			<fieldname>probe_timeout</fieldname>
			<description>Enter the frequency in seconds that varnish will wait for a backend probe response.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Probe Window</fielddescr>
			<fieldname>probe_window</fieldname>
			<description>Enter the value of how many of the latest polls that should be examined.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>Probe Threshold</fielddescr>
			<fieldname>probe_threshold</fieldname>
			<description>Enter the value of how many of those must have succeeded for us to consider the backend healthy.</description>
			<type>input</type>
		</field>
		<field>
			<fielddescr>URL Mappings</fielddescr>
			<fieldname>URL Mappings</fieldname>
			<type>listtopic</type>
			<name>If you plan to load balance to this backend then visit the LB Directors tab and do not add any mappings below.</name>
		</field>
		<field>
			<fielddescr>Map URLs</fielddescr>
			<fieldname>MapURLs</fieldname>
		    <type>rowhelper</type>
		    <rowhelper>
				<rowhelperfield>
				    <fielddescr>Match type</fielddescr>
				    <fieldname>fieldtype</fieldname>
				    <description>Select the field type that you would like to use in matching the URL.</description>
					<type>select</type>
					<options>
						<option>
							<name>Equals</name>
							<value>==</value>
						</option>
						<option>
							<name>Regex</name>
							<value>~</value>
						</option>
					</options>
				</rowhelperfield>
				<rowhelperfield>
				    <fielddescr>URL</fielddescr>
				    <fieldname>urlmapping</fieldname>
				    <description>Enter the URL that will be mapped to this backend.</description>
				    <type>input</type>
					<size>30</size>
				</rowhelperfield>
			</rowhelper>
		</field>
	</fields>
	<custom_php_install_command>
		varnish_install();
	</custom_php_install_command>
	<custom_php_command_before_form>
	</custom_php_command_before_form>
	<custom_delete_php_command>
		sync_package_varnish();
		create_varnish_rcd_file();
		varnish_start();
	</custom_delete_php_command>	
	<custom_php_resync_config_command>
		sync_package_varnish();
		create_varnish_rcd_file();
		varnish_start();
	</custom_php_resync_config_command>
	<custom_php_validation_command>
		varnish_backends_post_validate($_POST, &amp;$input_errors);
	</custom_php_validation_command>
</packagegui>