. 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: nat */ ##|+PRIV ##|*IDENT=page-firewall-nat-outbound-edit ##|*NAME=Firewall: NAT: Outbound: Edit page ##|*DESCR=Allow access to the 'Firewall: NAT: Outbound: Edit' page. ##|*MATCH=firewall_nat_out_edit.php* ##|-PRIV require("guiconfig.inc"); require("filter.inc"); require("shaper.inc"); if (!is_array($config['nat']['advancedoutbound'])) $config['nat']['advancedoutbound'] = array(); if (!is_array($config['nat']['advancedoutbound']['rule'])) { $config['nat']['advancedoutbound']['rule'] = array(); } $a_out = &$config['nat']['advancedoutbound']['rule']; $id = $_GET['id']; if (isset($_POST['id'])) { $id = $_POST['id']; } if (isset($_GET['dup'])) { $id = $_GET['dup']; $after = $_GET['dup']; } else unset($after); if (isset($id) && $a_out[$id]) { $pconfig['protocol'] = $a_out[$id]['protocol']; list($pconfig['source'],$pconfig['source_subnet']) = explode('/', $a_out[$id]['source']['network']); $pconfig['sourceport'] = $a_out[$id]['sourceport']; address_to_pconfig($a_out[$id]['destination'], $pconfig['destination'], $pconfig['destination_subnet'], $pconfig['destination_not'], $none, $none); $pconfig['dstport'] = $a_out[$id]['dstport']; $pconfig['natport'] = $a_out[$id]['natport']; $pconfig['target'] = $a_out[$id]['target']; $pconfig['interface'] = $a_out[$id]['interface']; if (!$pconfig['interface']) { $pconfig['interface'] = "wan"; } $pconfig['descr'] = $a_out[$id]['descr']; $pconfig['nonat'] = $a_out[$id]['nonat']; $pconfig['staticnatport'] = isset($a_out[$id]['staticnatport']); $pconfig['nosync'] = isset($a_out[$id]['nosync']); } else { $pconfig['source_subnet'] = 24; $pconfig['destination'] = "any"; $pconfig['destination_subnet'] = 24; $pconfig['interface'] = "wan"; } if (isset($_GET['dup'])) { unset($id); } if ($_POST) { if ($_POST['destination_type'] == "any") { $_POST['destination'] = "any"; $_POST['destination_subnet'] = 24; } if ($_POST['source_type'] == "any") { $_POST['source'] = "any"; $_POST['source_subnet'] = 24; } unset($input_errors); $pconfig = $_POST; /* input validation */ $reqdfields = explode(" ", "interface protocol source source_subnet destination destination_subnet"); $reqdfieldsn = array(gettext("Interface"),gettext("Protocol"),gettext("Source"),gettext("Source bit count"),gettext("Destination"),gettext("Destination bit count")); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if($_POST['sourceport'] <> "" && !is_port($_POST['sourceport'])) $input_errors[] = gettext("You must supply either a valid port for the source port entry."); if($_POST['dstport'] <> "" and !is_port($_POST['dstport'])) $input_errors[] = gettext("You must supply either a valid port for the destination port entry."); if($_POST['natport'] <> "" and !is_port($_POST['natport'])) $input_errors[] = gettext("You must supply either a valid port for the nat port entry."); if ($_POST['source_type'] != "any") { if ($_POST['source'] && !is_ipaddr($_POST['source']) && $_POST['source'] <> "any") { $input_errors[] = gettext("A valid source must be specified."); } } if ($_POST['source_subnet'] && !is_numericint($_POST['source_subnet'])) { $input_errors[] = gettext("A valid source bit count must be specified."); } if ($_POST['sourceport'] && !is_numericint($_POST['sourceport'])) { $input_errors[] = gettext("A valid source port must be specified."); } if ($_POST['destination_type'] != "any") { if ($_POST['destination'] && !is_ipaddr($_POST['destination'])) { $input_errors[] = gettext("A valid destination must be specified."); } } if ($_POST['destination_subnet'] && !is_numericint($_POST['destination_subnet'])) { $input_errors[] = gettext("A valid destination bit count must be specified."); } if ($_POST['destination_type'] == "any") { if ($_POST['destination_not']) { $input_errors[] = gettext("Negating destination address of \"any\" is invalid."); } } if ($_POST['nonat'] && $_POST['staticnatport']) { $input_errors[] = gettext("Static port cannot be used with No NAT."); } if ($_POST['target'] && !is_ipaddr($_POST['target'])) { $input_errors[] = gettext("A valid target IP address must be specified."); } /* if user has selected any as source, set it here */ if($_POST['source_type'] == "any") { $osn = "any"; } else { $osn = gen_subnet($_POST['source'], $_POST['source_subnet']) . "/" . $_POST['source_subnet']; } /* check for existing entries */ if ($_POST['destination_type'] == "any") { $ext = "any"; } else { $ext = gen_subnet($_POST['destination'], $_POST['destination_subnet']) . "/" . $_POST['destination_subnet']; } foreach ($a_out as $natent) { if (isset($id) && ($a_out[$id]) && ($a_out[$id] === $natent)) { continue; } if (!$natent['interface']) { $natent['interface'] == "wan"; } } if (!$input_errors) { $natent = array(); $natent['source']['network'] = $osn; $natent['sourceport'] = $_POST['sourceport']; $natent['descr'] = $_POST['descr']; $natent['target'] = $_POST['target']; $natent['interface'] = $_POST['interface']; /* static-port */ if(isset($_POST['staticnatport'])) { $natent['staticnatport'] = true; } else { unset($natent['staticnatport']); } /* if user has selected not nat, set it here */ if(isset($_POST['nonat'])) { $natent['nonat'] = true; } else { unset($natent['nonat']); } if ($_POST['protocol'] && $_POST['protocol'] != "any") $natent['protocol'] = $_POST['protocol']; else unset($natent['protocol']); if ($ext == "any") { $natent['destination']['any'] = true; } else { $natent['destination']['address'] = $ext; } if($_POST['natport'] != "") { $natent['natport'] = $_POST['natport']; } else { unset($natent['natport']); } if($_POST['dstport'] != "") { $natent['dstport'] = $_POST['dstport']; } else { unset($natent['dstport']); } if($_POST['nosync'] == "yes") { $natent['nosync'] = true; } else { unset($natent['nosync']); } if (isset($_POST['destination_not']) && $ext != "any") { $natent['destination']['not'] = true; } if (isset($id) && $a_out[$id]) { $a_out[$id] = $natent; } else { if (is_numeric($after)) { array_splice($a_out, $after+1, 0, array($natent)); } else { $a_out[] = $natent; } } mark_subsystem_dirty('natconf'); write_config(); header("Location: firewall_nat_out.php"); exit; } } $pgtitle = array(gettext("Firewall"),gettext("NAT"),gettext("Outbound"),gettext("Edit")); $closehead = false; include("head.inc"); ?>
>




"," ");?>
:  
:   /
 
:  
>


:  
:   /
 
:  
:  
 
:  
 
:   >
>

  " onclick="history.back()">