Add underscores to is_port* function names

(cherry picked from commit 593e9fe32d)
This commit is contained in:
Phil Davis 2017-03-27 22:15:20 +05:45 committed by Renato Botelho
parent 33cb7cc272
commit e4958a8fe2
10 changed files with 25 additions and 25 deletions

View File

@ -668,7 +668,7 @@ function filter_generate_nested_alias_recurse($name, $alias, &$aliasnesting, &$a
$tmpline = filter_generate_nested_alias_recurse($name, $aliastable[$address], $aliasnesting, $aliasaddrnesting, $use_filterdns);
}
} else if (!isset($aliasaddrnesting[$address])) {
if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_portorrange($address)) && is_hostname($address)) {
if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_port_or_range($address)) && is_hostname($address)) {
if (!isset($filterdns["{$address}{$name}"])) {
$use_filterdns = true;
$filterdns["{$address}{$name}"] = "pf {$address} {$name}\n";
@ -2744,7 +2744,7 @@ function filter_generate_user_rule($rule) {
return "# {$error_text}";
}
if ($rule['source']['port']
&& !is_portorrange(str_replace("-", ":", $rule['source']['port']))) {
&& !is_port_or_range(str_replace("-", ":", $rule['source']['port']))) {
$error_text = "";
// It is not a literal port or port range, so alias should exist, and expand to something non-empty
@ -2760,7 +2760,7 @@ function filter_generate_user_rule($rule) {
}
}
if ($rule['destination']['port']
&& !is_portorrange(str_replace("-", ":", $rule['destination']['port']))) {
&& !is_port_or_range(str_replace("-", ":", $rule['destination']['port']))) {
$error_text = "";
// It is not a literal port or port range, so alias should exist, and expand to something non-empty

View File

@ -2241,7 +2241,7 @@ function parse_aliases_file($filename, $type = "url", $max_items = -1, $kflc = f
$tmp = $tmp_str;
}
$valid = (($type == "url" || $type == "urltable") && (is_ipaddr($tmp) || is_subnet($tmp))) ||
(($type == "url_ports" || $type == "urltable_ports") && is_portorrange($tmp));
(($type == "url_ports" || $type == "urltable_ports") && is_port_or_range($tmp));
if ($valid) {
$items[] = $tmp;
if (count($items) == $max_items) {

View File

@ -1162,12 +1162,12 @@ function is_portrange($portrange) {
}
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") */
function is_portorrange($port) {
function is_port_or_range($port) {
return (is_port($port) || is_portrange($port));
}
/* returns true if $port is a valid port number or an alias thereof */
function is_portoralias($port) {
function is_port_or_alias($port) {
global $config;
if (is_alias($port)) {
@ -1185,8 +1185,8 @@ function is_portoralias($port) {
}
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") or an alias thereof */
function is_portorrangeoralias($port) {
return (is_portoralias($port) || is_portrange($port));
function is_port_or_range_or_alias($port) {
return (is_port_or_alias($port) || is_portrange($port));
}
/* create ranges of sequential port numbers (200:215) and remove duplicates */
@ -1827,7 +1827,7 @@ function alias_expand($name) {
}
}
return "\${$name}";
} else if (is_ipaddr($name) || is_subnet($name) || is_portorrange($name)) {
} else if (is_ipaddr($name) || is_subnet($name) || is_port_or_range($name)) {
return "{$name}";
} else {
return null;

View File

@ -463,7 +463,7 @@ if ($_POST) {
}
}
} else if ($_POST['type'] == "port") {
if (!is_portorrange($input_address)) {
if (!is_port_or_range($input_address)) {
$input_errors[] = sprintf(gettext("%s is not a valid port or alias."), $input_address);
}
} else if ($_POST['type'] == "host" || $_POST['type'] == "network") {

View File

@ -153,7 +153,7 @@ if ($_POST) {
if ($tab == "port") {
// Port alias
if (!empty($impip)) {
if (is_portorrange($impip)) {
if (is_port_or_range($impip)) {
$imported_ips[] = $impip;
$imported_descs[] = $impdesc;
} else {

View File

@ -292,20 +292,20 @@ if ($_POST) {
$input_errors[] = sprintf(gettext("Redirect target IP must be IPv4."));
}
if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
}
if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
}
if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
}
if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
}
if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_port_or_alias($_POST['localbeginport']))) {
$input_errors[] = sprintf(gettext("A valid redirect target port must be specified. It must be a port alias or integer between 1 and 65535."), $_POST['localbeginport']);
}

View File

@ -206,15 +206,15 @@ if ($_POST) {
$_POST['natport'] = trim($_POST['natport']);
}
if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_portorrangeoralias($_POST['sourceport'])) {
if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_port_or_range_or_alias($_POST['sourceport'])) {
$input_errors[] = gettext("A valid port or port alias must be supplied for the source port entry.");
}
if ($protocol_uses_ports && $_POST['dstport'] <> "" && !is_portorrangeoralias($_POST['dstport'])) {
if ($protocol_uses_ports && $_POST['dstport'] <> "" && !is_port_or_range_or_alias($_POST['dstport'])) {
$input_errors[] = gettext("A valid port or port alias must be supplied for the destination port entry.");
}
if ($protocol_uses_ports && $_POST['natport'] <> "" && !is_portorrangeoralias($_POST['natport']) && !isset($_POST['nonat'])) {
if ($protocol_uses_ports && $_POST['natport'] <> "" && !is_port_or_range_or_alias($_POST['natport']) && !isset($_POST['nonat'])) {
$input_errors[] = gettext("A valid port must be supplied for the NAT port entry.");
}

View File

@ -511,16 +511,16 @@ if ($_POST) {
$_POST['dstendport'] = 0;
}
if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcbeginport']);
}
if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end source port. It must be a port alias or integer between 1 and 65535."), $_POST['srcendport']);
}
if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid start destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstbeginport']);
}
if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
$input_errors[] = sprintf(gettext("%s is not a valid end destination port. It must be a port alias or integer between 1 and 65535."), $_POST['dstendport']);
}
if (!$_POST['srcbeginport_cust'] && $_POST['srcendport_cust']) {

View File

@ -129,7 +129,7 @@ if ($_POST) {
$input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']);
}
if (!is_portoralias($_POST['port'])) {
if (!is_port_or_alias($_POST['port'])) {
$input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");
}

View File

@ -125,7 +125,7 @@ if ($_POST) {
$input_errors[] = gettext("The 'name' field must be 32 characters or less.");
}
if ($_POST['port'] != "" && !is_portoralias($_POST['port'])) {
if ($_POST['port'] != "" && !is_port_or_alias($_POST['port'])) {
$input_errors[] = gettext("The port must be an integer between 1 and 65535, a port alias, or left blank.");
}