diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index adf38188b5..1571fda1d3 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -84,6 +84,34 @@ if (!is_array($config['nat']['rule'])) { $a_nat = &$config['nat']['rule']; +$iflist = get_configured_interface_with_descr(false, true); + +foreach ($iflist as $if => $ifdesc) { + if (have_ruleint_access($if)) { + $interfaces[$if] = $ifdesc; + } +} + +if ($config['l2tp']['mode'] == "server") { + if (have_ruleint_access("l2tp")) { + $interfaces['l2tp'] = gettext("L2TP VPN"); + } +} + +if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { + $interfaces['pppoe'] = gettext("PPPoE Server"); +} + +/* add ipsec interfaces */ +if (ipsec_enabled() && have_ruleint_access("enc0")) { + $interfaces["enc0"] = gettext("IPsec"); +} + +/* add openvpn/tun interfaces */ +if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { + $interfaces["openvpn"] = gettext("OpenVPN"); +} + if (is_numericint($_GET['id'])) { $id = $_GET['id']; } @@ -284,6 +312,10 @@ if ($_POST) { $_POST['localip'] = trim($_POST['localip']); } + if (!array_key_exists($_POST['interface'], $interfaces)) { + $input_errors[] = gettext("The submitted interface does not exist."); + } + if (!isset($_POST['nordr']) && ($_POST['localip'] && !is_ipaddroralias($_POST['localip']))) { $input_errors[] = sprintf(gettext("\"%s\" is not a valid redirect target IP address or host alias."), $_POST['localip']); } @@ -694,34 +726,6 @@ $section->addInput(new Form_Checkbox( $pconfig['nordr'] ))->setHelp('This option is rarely needed. Don\'t use this without thorough knowledge of the implications.'); -$iflist = get_configured_interface_with_descr(false, true); - -foreach ($iflist as $if => $ifdesc) { - if (have_ruleint_access($if)) { - $interfaces[$if] = $ifdesc; - } -} - -if ($config['l2tp']['mode'] == "server") { - if (have_ruleint_access("l2tp")) { - $interfaces['l2tp'] = gettext("L2TP VPN"); - } -} - -if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) { - $interfaces['pppoe'] = gettext("PPPoE Server"); -} - -/* add ipsec interfaces */ -if (ipsec_enabled() && have_ruleint_access("enc0")) { - $interfaces["enc0"] = gettext("IPsec"); -} - -/* add openvpn/tun interfaces */ -if ($config['openvpn']["openvpn-server"] || $config['openvpn']["openvpn-client"]) { - $interfaces["openvpn"] = gettext("OpenVPN"); -} - $section->addInput(new Form_Select( 'interface', '*Interface', @@ -1273,7 +1277,7 @@ events.push(function() { - dst_change($('#interface').val(),'',''); + dst_change($('#interface').val(),'','');