Commit c9fc7a45 authored by Phil Davis's avatar Phil Davis Committed by Franco Fichtner

Allow blank source port in diag_testport

Reported by forum https://forum.pfsense.org/index.php?topic=86146.0
Also, if there are input validation errors, save the user-entered data and re-display it, making it easier for the user to just correct the data in error and press Test again. It was blanking out all the entered data.
parent ce7c30a8
......@@ -33,10 +33,10 @@ $pgtitle = array(gettext("Diagnostics"), gettext("Test Port"));
require("guiconfig.inc");
define('NC_TIMEOUT', 10);
$do_testport = false;
if ($_POST || $_REQUEST['host']) {
unset($input_errors);
unset($do_testport);
/* input validation */
$reqdfields = explode(" ", "host port");
......@@ -51,7 +51,7 @@ if ($_POST || $_REQUEST['host']) {
$input_errors[] = gettext("Please enter a valid port number.");
}
if (!is_numeric($_REQUEST['srcport']) || !is_port($_REQUEST['srcport'])) {
if (($_REQUEST['srcport'] != "") && (!is_numeric($_REQUEST['srcport']) || !is_port($_REQUEST['srcport']))) {
$input_errors[] = gettext("Please enter a valid source port number, or leave the field blank.");
}
......@@ -64,21 +64,16 @@ if ($_POST || $_REQUEST['host']) {
if (!$input_errors) {
$do_testport = true;
$timeout = NC_TIMEOUT;
}
/* Save these request vars even if there were input errors. Then the fields are refilled for the user to correct. */
$host = $_REQUEST['host'];
$sourceip = $_REQUEST['sourceip'];
$port = $_REQUEST['port'];
$srcport = $_REQUEST['srcport'];
$showtext = isset($_REQUEST['showtext']);
$ipprotocol = $_REQUEST['ipprotocol'];
$timeout = NC_TIMEOUT;
}
}
if (!isset($do_testport)) {
$do_testport = false;
$host = '';
$port = '';
$srcport = '';
unset($showtext);
}
include("head.inc"); ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment