. 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. */ /* pfSense_MODULE: routing */ ##|+PRIV ##|*IDENT=page-services-loadbalancer-relay-action-edit ##|*NAME=Services: Load Balancer: Relay Action: Edit page ##|*DESCR=Allow access to the 'Services: Load Balancer: Relay Action: Edit' page. ##|*MATCH=load_balancer_relay_action_edit.php* ##|-PRIV require("guiconfig.inc"); $referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/load_balancer_relay_action.php'); if (!is_array($config['load_balancer']['lbaction'])) { $config['load_balancer']['lbaction'] = array(); } $a_action = &$config['load_balancer']['lbaction']; if (is_numericint($_GET['id'])) $id = $_GET['id']; if (isset($_POST['id']) && is_numericint($_POST['id'])) $id = $_POST['id']; if (isset($id) && $a_action[$id]) { $pconfig = array(); $pconfig = $a_action[$id]; } else { // XXX - TODO, this isn't sane for this page :) /* Some sane page defaults */ $pconfig['protocol'] = 'http'; $pconfig['direction'] = 'request'; $pconfig['type'] = 'cookie'; $pconfig['action'] = 'change'; } $changedesc = gettext("Load Balancer: Relay Action:") . " "; $changecount = 0; $kv = array('key', 'value'); $vk = array('value', 'key'); $hr_actions = array(); $hr_actions['append'] = $vk; $hr_actions['change'] = $kv; $hr_actions['expect'] = $vk; $hr_actions['filter'] = $vk; $hr_actions['hash'] = 'key'; $hr_actions['log'] = 'key'; // mark is disabled until I can figure out how to make the display clean //$hr_actions['mark'] = array('value', 'key', 'id'); //$hr_actions[] = 'label'; //$hr_actions[] = 'no label'; $hr_actions['remove'] = 'key'; //$hr_actions[] = 'return error'; /* Setup decision tree */ $action = array(); $actions['protocol']['http'] = 'HTTP'; $actions['protocol']['tcp'] = 'TCP'; $actions['protocol']['dns'] = 'DNS'; $actions['direction'] = array(); $actions['direction']['request'] = array(); $actions['direction']['request']['cookie'] = $hr_actions; $actions['direction']['request']['header'] = $hr_actions; $actions['direction']['request']['path'] = $hr_actions; $actions['direction']['request']['query'] = $hr_actions; $actions['direction']['request']['url'] = $hr_actions; $actions['direction']['response'] = array(); $actions['direction']['response']['cookie'] = $hr_actions; $actions['direction']['response']['header'] = $hr_actions; //$action['http']['tcp'] = array(); //$action['http']['ssl'] = array(); if ($_POST) { $changecount++; unset($input_errors); $pconfig = $_POST; // Peel off the action and type from the post and fix $pconfig $action = explode('_', $pconfig['action']); $pconfig['action'] = $action[2]; $pconfig['type'] = $action[1]; unset($pconfig["type_{$pconfig['direction']}"]); /* input validation */ $reqdfields = explode(" ", "name protocol direction action descr"); $reqdfieldsn = array(gettext("Name"),gettext("Protocol"),gettext("Direction"),gettext("Action"),gettext("Description")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); /* Ensure that our monitor names are unique */ for ($i=0; isset($config['load_balancer']['lbactions'][$i]); $i++) if (($_POST['name'] == $config['load_balancer']['lbactions'][$i]['name']) && ($i != $id)) $input_errors[] = gettext("This action name has already been used. Action names must be unique."); if (strpos($_POST['name'], " ") !== false) $input_errors[] = gettext("You cannot use spaces in the 'name' field."); if (!$input_errors) { $actent = array(); if(isset($id) && $a_action[$id]) $actent = $a_action[$id]; if($actent['name'] != "") $changedesc .= " " . sprintf(gettext("modified '%s' action:"), $actent['name']); update_if_changed("name", $actent['name'], $pconfig['name']); update_if_changed("protocol", $actent['protocol'], $pconfig['protocol']); update_if_changed("type", $actent['type'], $pconfig['type']); update_if_changed("direction", $actent['direction'], $pconfig['direction']); update_if_changed("description", $actent['descr'], $pconfig['descr']); update_if_changed("action", $actent['action'], $pconfig['action']); switch ($pconfig['action']) { case "append": case "change": case "expect": case "filter": { update_if_changed("value", $actent['options']['value'], $pconfig['option_action_value']); update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); break; } case "hash": case "log": { update_if_changed("key", $actent['options']['akey'], $pconfig['option_action_key']); break; } } if (isset($id) && $a_action[$id]) { // XXX - TODO /* modify all virtual servers with this name */ // for ($i = 0; isset($config['load_balancer']['virtual_server'][$i]); $i++) { // if ($config['load_balancer']['virtual_server'][$i]['protocol'] == $a_protocol[$id]['name']) // $config['load_balancer']['virtual_server'][$i]['protocol'] = $protent['name']; // } $a_action[$id] = $actent; } else { $a_action[] = $actent; } if ($changecount > 0) { /* Mark config dirty */ mark_subsystem_dirty('loadbalancer'); write_config($changedesc); } header("Location: load_balancer_relay_action.php"); exit; } } $pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Relay Action"),gettext("Edit")); $shortcut_section = "relayd"; include("head.inc"); $types = array("http" => gettext("HTTP"), "tcp" => gettext("TCP"), "dns" => gettext("DNS")); ?>