#! /usr/bin/perl -wT
# vim: ft=xml:

#----------------------------------------------------------------------
# heading       : Configuration
# description   : OpenVPN Site to Site
# navigation    : 6000 6750
#----------------------------------------------------------------------

#----------------------------------------------------------------------
# copyright (C) 2010 Firewall Services
# Dejan Florian, Berteaud Daniel <daniel@firewall-services.com>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
# 
#----------------------------------------------------------------------


use strict;
use warnings;
use esmith::FormMagick;
use esmith::FormMagick::Panel::openvpns2s;

my $f = esmith::FormMagick::Panel::openvpns2s->new();
$f->display();

__DATA__
<form   title="FORM_TITLE" 
    header="/etc/e-smith/web/common/head.tmpl" 
    footer="/etc/e-smith/web/common/foot.tmpl">

    #----------------------------------------------------------------
    # MAIN PAGE
    #----------------------------------------------------------------
    <page name="FIRST_PAGE" pre-event="print_status_message()">
        <field type="literal" id="main_desc" value=""> 
            <description>DESC_MAIN_PAGE</description>
        </field>

        <subroutine src="print_section_bar()"/>

        <field type="literal" id="client_label" value="">
            <description>LABEL_CLIENTS</description>
        </field>

        <subroutine src="print_custom_button('ADD_CLIENT', 'CREATE_OR_MODIFY_CLIENT_CONF_PAGE')"/>

        <subroutine src="print_conf_table('client')"/>

        <subroutine src="print_section_bar()"/>

        <field type="literal" id="server_label" value="">
            <description>LABEL_SERVERS</description>
        </field>

        <subroutine src="print_custom_button('ADD_SERVER', 'CREATE_OR_MODIFY_SERVER_CONF_PAGE')"/>

        <subroutine src="print_conf_table('server')"/>

    </page>

    #----------------------------------------------------------------
    # CLIENT CONFIGURATION PAGE
    #----------------------------------------------------------------
    <page name="CREATE_OR_MODIFY_CLIENT_CONF_PAGE" pre-event="turn_off_buttons()" post-event="write_db_conf('client')">

        <field type="literal" id="add_client_desc" value="">
            <description>DESC_ADD_CLIENT_PAGE</description>
        </field>
                
        <subroutine src="print_section_bar()"/>

        <subroutine src="print_conf_name_field()"/>

        <field type="text" id="comment" validation="validate_description()">
            <description>DESC_COMMENT</description>
            <label>LABEL_COMMENT</label>
        </field>

        <field type="select" id="status" value="" options="'disabled' => 'DISABLED', 'enabled' => 'ENABLED'">
            <description>DESC_STATUS</description>
            <label>LABEL_STATUS</label>
        </field>

        <field type="select" id="auth" options="'TLS' => 'TLS', 'SharedKey' => 'SHARED_KEY'">
            <description>DESC_AUTH</description>
            <label>LABEL_AUTH</label>
        </field>

        <field type="select" id="hmac"  options="get_digests_options()" value="get_current_hmac()">
            <description>DESC_HMAC</description>
            <label>LABEL_HMAC</label>
        </field>

        <field type="select" id="cipher" options="get_ciphers_options()" value="get_current_cipher()">
            <description>DESC_CIPHER</description>
            <label>LABEL_CIPHER</label>
        </field>

        <field type="text" id="remote_host" validation="is_hostname_or_ip()">
            <description>DESC_REMOTE_HOST</description>
            <label>LABEL_REMOTE_HOST</label>
        </field>
                
        <field type="text" id="port" validation="is_valid_port()">
            <description>DESC_REMOTE_PORT</description>
            <label>LABEL_REMOTE_PORT</label>
        </field>

        <field type="text" id="local_ip" validation="is_valid_vpn_ip()">
            <description>DESC_LOCAL_IP</description>
            <label>LABEL_LOCAL_IP</label>
        </field>
                
        <field type="text" id="remote_ip" validation="is_valid_vpn_ip()">
            <description>DESC_REMOTE_IP</description>
            <label>LABEL_REMOTE_IP</label>
        </field>

        <field type="select" id="SnatOutbound" value="" options="'disabled' => 'DISABLED', 'enabled' => 'ENABLED'">
            <description>DESC_SNAT</description>
            <label>LABEL_SNAT</label>
        </field>


        <field type="text"  size="53" id="remote_net" validation="is_valid_net_or_empty()">
            <description>DESC_REMOTE_NET</description>
            <label>LABEL_REMOTE_NET</label>
        </field>

        <subroutine src="print_button('NEXT')"/>
    </page>

    #----------------------------------------------------------------
    # SERVER CONFIGURATION PAGE
    #----------------------------------------------------------------
    <page name="CREATE_OR_MODIFY_SERVER_CONF_PAGE" pre-event="turn_off_buttons()" post-event="write_db_conf('server')">

        <field type="literal" id="add_server" value="">
            <description>DESC_ADD_SERVER_PAGE</description>
        </field>
                
        <subroutine src="print_section_bar()"/>

        <subroutine src="print_conf_name_field()"/>

        <field type="text" id="comment" validation="validate_description()">
            <description>DESC_COMMENT</description>
            <label>LABEL_COMMENT</label>
        </field>

        <field type="select" id="status" options="'disabled' => 'DISABLED', 'enabled' => 'ENABLED'">
            <description>DESC_STATUS</description>
            <label>LABEL_STATUS</label>
        </field>

        <field type="select" id="auth" options="'TLS' => 'TLS', 'SharedKey' => 'SHARED_KEY'">
            <description>DESC_AUTH</description>
            <label>LABEL_AUTH</label>
        </field>

       <field type="select" id="hmac"  options="get_digests_options()" value="get_current_hmac()">
            <description>DESC_HMAC</description>
            <label>LABEL_HMAC</label>
        </field>

        <field type="select" id="cipher" options="get_ciphers_options()" value="get_current_cipher()">
            <description>DESC_CIPHER</description>
            <label>LABEL_CIPHER</label>
        </field>

        <field type="text" id="port" validation="is_valid_and_available_port()">
            <description>DESC_LOCAL_PORT</description>
            <label>LABEL_LOCAL_PORT</label>
        </field>
                
        <field type="text" id="local_ip" validation="is_valid_vpn_ip()">
            <description>DESC_LOCAL_IP</description>
            <label>LABEL_LOCAL_IP</label>
        </field>
               
        <field type="text" id="remote_ip" validation="is_valid_vpn_ip()">
            <description>DESC_REMOTE_IP</description>
            <label>LABEL_REMOTE_IP</label>
        </field>

        <field type="text" size="53" id="remote_net" validation="is_valid_net_or_empty()">
            <description>DESC_REMOTE_NET</description>
            <label>LABEL_REMOTE_NET</label>
        </field>

        <subroutine src="print_button('NEXT')"/>

    </page>

    <page name="CONFIG_CERT_PAGE" pre-event="print_status_message()" post-event="write_pem()">
        <field type="literal" id="cert_conf" value="">
            <description>DESC_CONFIGURE_CERT</description>
        </field>
        <subroutine src="print_cert_fields()"/>
        <subroutine src="print_button('SAVE')"/>
    </page>

    <page name="REMOVE_CONF_PAGE" pre-event="turn_off_buttons()" post-event="remove_conf()">
        <field type="literal" id="des_remove_conf">
            <description>DESC_REMOVE_CONF</description>
        </field>

        <subroutine src="print_conf_to_remove()"/>
    </page>

    <page name="RELOAD_PAGE" pre-event="turn_off_buttons()"  post-event="reload()">
        <field type="literal" id="conf_name">
            <description>DESC_RELOAD</description>
        </field>
        <subroutine src="print_button('NEXT')"/>
    </page>

</form>
