Refactor is_port_or functions

This commit is contained in:
Phil Davis 2017-03-27 22:42:34 +05:45
parent 593e9fe32d
commit fe108b671d
No known key found for this signature in database
GPG Key ID: 340A5689A513CA23

View File

@ -1129,8 +1129,8 @@ 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_port_or_alias($port) {
/* returns true if $port is an alias that is a port type */
function is_portalias($port) {
global $config;
if (is_alias($port)) {
@ -1141,15 +1141,18 @@ function is_port_or_alias($port) {
}
}
}
return false;
} else {
return is_port($port);
}
return false;
}
/* returns true if $port is a valid port number or an alias thereof */
function is_port_or_alias($port) {
return (is_port($port) || is_portalias($port));
}
/* returns true if $port is a valid TCP/UDP port number or range ("<port>:<port>") or an alias thereof */
function is_port_or_range_or_alias($port) {
return (is_port_or_alias($port) || is_portrange($port));
return (is_port($port) || is_portrange($port) || is_portalias($port));
}
/* create ranges of sequential port numbers (200:215) and remove duplicates */