Revision 593e9fe3
Added by Phil Davis over 8 years ago
src/etc/inc/filter.inc | ||
---|---|---|
636 | 636 |
$tmpline = filter_generate_nested_alias_recurse($name, $aliastable[$address], $aliasnesting, $aliasaddrnesting, $use_filterdns); |
637 | 637 |
} |
638 | 638 |
} else if (!isset($aliasaddrnesting[$address])) { |
639 |
if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_portorrange($address)) && is_hostname($address)) {
|
|
639 |
if (!is_ipaddr($address) && !is_subnet($address) && !((($alias_type == 'port') || ($alias_type == 'url_ports')) && is_port_or_range($address)) && is_hostname($address)) {
|
|
640 | 640 |
if (!isset($filterdns["{$address}{$name}"])) { |
641 | 641 |
$use_filterdns = true; |
642 | 642 |
$filterdns["{$address}{$name}"] = "pf {$address} {$name}\n"; |
... | ... | |
2710 | 2710 |
return "# {$error_text}"; |
2711 | 2711 |
} |
2712 | 2712 |
if ($rule['source']['port'] |
2713 |
&& !is_portorrange(str_replace("-", ":", $rule['source']['port']))) {
|
|
2713 |
&& !is_port_or_range(str_replace("-", ":", $rule['source']['port']))) {
|
|
2714 | 2714 |
$error_text = ""; |
2715 | 2715 |
|
2716 | 2716 |
// It is not a literal port or port range, so alias should exist, and expand to something non-empty |
... | ... | |
2726 | 2726 |
} |
2727 | 2727 |
} |
2728 | 2728 |
if ($rule['destination']['port'] |
2729 |
&& !is_portorrange(str_replace("-", ":", $rule['destination']['port']))) {
|
|
2729 |
&& !is_port_or_range(str_replace("-", ":", $rule['destination']['port']))) {
|
|
2730 | 2730 |
$error_text = ""; |
2731 | 2731 |
|
2732 | 2732 |
// It is not a literal port or port range, so alias should exist, and expand to something non-empty |
src/etc/inc/pfsense-utils.inc | ||
---|---|---|
2153 | 2153 |
$tmp = $tmp_str; |
2154 | 2154 |
} |
2155 | 2155 |
$valid = (($type == "url" || $type == "urltable") && (is_ipaddr($tmp) || is_subnet($tmp))) || |
2156 |
(($type == "url_ports" || $type == "urltable_ports") && is_portorrange($tmp));
|
|
2156 |
(($type == "url_ports" || $type == "urltable_ports") && is_port_or_range($tmp));
|
|
2157 | 2157 |
if ($valid) { |
2158 | 2158 |
$items[] = $tmp; |
2159 | 2159 |
if (count($items) == $max_items) { |
src/etc/inc/util.inc | ||
---|---|---|
1125 | 1125 |
} |
1126 | 1126 |
|
1127 | 1127 |
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") */ |
1128 |
function is_portorrange($port) {
|
|
1128 |
function is_port_or_range($port) {
|
|
1129 | 1129 |
return (is_port($port) || is_portrange($port)); |
1130 | 1130 |
} |
1131 | 1131 |
|
1132 | 1132 |
/* returns true if $port is a valid port number or an alias thereof */ |
1133 |
function is_portoralias($port) {
|
|
1133 |
function is_port_or_alias($port) {
|
|
1134 | 1134 |
global $config; |
1135 | 1135 |
|
1136 | 1136 |
if (is_alias($port)) { |
... | ... | |
1148 | 1148 |
} |
1149 | 1149 |
|
1150 | 1150 |
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") or an alias thereof */ |
1151 |
function is_portorrangeoralias($port) {
|
|
1152 |
return (is_portoralias($port) || is_portrange($port));
|
|
1151 |
function is_port_or_range_or_alias($port) {
|
|
1152 |
return (is_port_or_alias($port) || is_portrange($port));
|
|
1153 | 1153 |
} |
1154 | 1154 |
|
1155 | 1155 |
/* create ranges of sequential port numbers (200:215) and remove duplicates */ |
... | ... | |
1791 | 1791 |
} |
1792 | 1792 |
} |
1793 | 1793 |
return "\${$name}"; |
1794 |
} else if (is_ipaddr($name) || is_subnet($name) || is_portorrange($name)) {
|
|
1794 |
} else if (is_ipaddr($name) || is_subnet($name) || is_port_or_range($name)) {
|
|
1795 | 1795 |
return "{$name}"; |
1796 | 1796 |
} else { |
1797 | 1797 |
return null; |
src/usr/local/www/firewall_aliases_edit.php | ||
---|---|---|
429 | 429 |
} |
430 | 430 |
} |
431 | 431 |
} else if ($_POST['type'] == "port") { |
432 |
if (!is_portorrange($input_address)) {
|
|
432 |
if (!is_port_or_range($input_address)) {
|
|
433 | 433 |
$input_errors[] = sprintf(gettext("%s is not a valid port or alias."), $input_address); |
434 | 434 |
} |
435 | 435 |
} else if ($_POST['type'] == "host" || $_POST['type'] == "network") { |
src/usr/local/www/firewall_aliases_import.php | ||
---|---|---|
121 | 121 |
if ($tab == "port") { |
122 | 122 |
// Port alias |
123 | 123 |
if (!empty($impip)) { |
124 |
if (is_portorrange($impip)) {
|
|
124 |
if (is_port_or_range($impip)) {
|
|
125 | 125 |
$imported_ips[] = $impip; |
126 | 126 |
$imported_descs[] = $impdesc; |
127 | 127 |
} else { |
src/usr/local/www/firewall_nat_edit.php | ||
---|---|---|
259 | 259 |
$input_errors[] = sprintf(gettext("Redirect target IP must be IPv4.")); |
260 | 260 |
} |
261 | 261 |
|
262 |
if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
|
|
262 |
if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
|
|
263 | 263 |
$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']); |
264 | 264 |
} |
265 |
if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
|
|
265 |
if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
|
|
266 | 266 |
$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']); |
267 | 267 |
} |
268 |
if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
|
|
268 |
if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
|
|
269 | 269 |
$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']); |
270 | 270 |
} |
271 |
if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
|
|
271 |
if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
|
|
272 | 272 |
$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']); |
273 | 273 |
} |
274 | 274 |
|
275 |
if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_portoralias($_POST['localbeginport']))) {
|
|
275 |
if ((strtoupper($_POST['proto']) == "TCP" || strtoupper($_POST['proto']) == "UDP" || strtoupper($_POST['proto']) == "TCP/UDP") && (!isset($_POST['nordr']) && !is_port_or_alias($_POST['localbeginport']))) {
|
|
276 | 276 |
$input_errors[] = sprintf(gettext("%s is not a valid redirect target port. It must be a port alias or integer between 1 and 65535."), $_POST['localbeginport']); |
277 | 277 |
} |
278 | 278 |
|
src/usr/local/www/firewall_nat_out_edit.php | ||
---|---|---|
189 | 189 |
$_POST['target'] = substr($_POST['target'], 1); |
190 | 190 |
} |
191 | 191 |
|
192 |
if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_portorrangeoralias($_POST['sourceport'])) {
|
|
192 |
if ($protocol_uses_ports && $_POST['sourceport'] <> "" && !is_port_or_range_or_alias($_POST['sourceport'])) {
|
|
193 | 193 |
$input_errors[] = gettext("A valid port or port alias must be supplied for the source port entry."); |
194 | 194 |
} |
195 | 195 |
|
196 |
if ($protocol_uses_ports && $_POST['dstport'] <> "" && !is_portorrangeoralias($_POST['dstport'])) {
|
|
196 |
if ($protocol_uses_ports && $_POST['dstport'] <> "" && !is_port_or_range_or_alias($_POST['dstport'])) {
|
|
197 | 197 |
$input_errors[] = gettext("A valid port or port alias must be supplied for the destination port entry."); |
198 | 198 |
} |
199 | 199 |
|
200 |
if ($protocol_uses_ports && $_POST['natport'] <> "" && !is_portorrangeoralias($_POST['natport']) && !isset($_POST['nonat'])) {
|
|
200 |
if ($protocol_uses_ports && $_POST['natport'] <> "" && !is_port_or_range_or_alias($_POST['natport']) && !isset($_POST['nonat'])) {
|
|
201 | 201 |
$input_errors[] = gettext("A valid port must be supplied for the NAT port entry."); |
202 | 202 |
} |
203 | 203 |
|
src/usr/local/www/firewall_rules_edit.php | ||
---|---|---|
491 | 491 |
$_POST['dstendport'] = 0; |
492 | 492 |
} |
493 | 493 |
|
494 |
if ($_POST['srcbeginport'] && !is_portoralias($_POST['srcbeginport'])) {
|
|
494 |
if ($_POST['srcbeginport'] && !is_port_or_alias($_POST['srcbeginport'])) {
|
|
495 | 495 |
$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']); |
496 | 496 |
} |
497 |
if ($_POST['srcendport'] && !is_portoralias($_POST['srcendport'])) {
|
|
497 |
if ($_POST['srcendport'] && !is_port_or_alias($_POST['srcendport'])) {
|
|
498 | 498 |
$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']); |
499 | 499 |
} |
500 |
if ($_POST['dstbeginport'] && !is_portoralias($_POST['dstbeginport'])) {
|
|
500 |
if ($_POST['dstbeginport'] && !is_port_or_alias($_POST['dstbeginport'])) {
|
|
501 | 501 |
$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']); |
502 | 502 |
} |
503 |
if ($_POST['dstendport'] && !is_portoralias($_POST['dstendport'])) {
|
|
503 |
if ($_POST['dstendport'] && !is_port_or_alias($_POST['dstendport'])) {
|
|
504 | 504 |
$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']); |
505 | 505 |
} |
506 | 506 |
if (!$_POST['srcbeginport_cust'] && $_POST['srcendport_cust']) { |
src/usr/local/www/load_balancer_pool_edit.php | ||
---|---|---|
93 | 93 |
$input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']); |
94 | 94 |
} |
95 | 95 |
|
96 |
if (!is_portoralias($_POST['port'])) {
|
|
96 |
if (!is_port_or_alias($_POST['port'])) {
|
|
97 | 97 |
$input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias."); |
98 | 98 |
} |
99 | 99 |
|
src/usr/local/www/load_balancer_virtual_server_edit.php | ||
---|---|---|
88 | 88 |
$input_errors[] = gettext("The 'name' field must be 32 characters or less."); |
89 | 89 |
} |
90 | 90 |
|
91 |
if ($_POST['port'] != "" && !is_portoralias($_POST['port'])) {
|
|
91 |
if ($_POST['port'] != "" && !is_port_or_alias($_POST['port'])) {
|
|
92 | 92 |
$input_errors[] = gettext("The port must be an integer between 1 and 65535, a port alias, or left blank."); |
93 | 93 |
} |
94 | 94 |
|
Also available in: Unified diff
Add underscores to is_port* function names