summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2015-01-31 14:25:28 +0100
committerRenato Botelho <garga@FreeBSD.org>2015-02-02 05:55:38 -0200
commit2cf35754c3aa1506148c101d71e288e436c62d18 (patch)
tree897691b67fc1f2eebd623c34463ef60cef55c8f0 /etc/inc/util.inc
parent87549136ccf9fe978619d087d5589e15ff8f2712 (diff)
downloadpfsense-2cf35754c3aa1506148c101d71e288e436c62d18.zip
pfsense-2cf35754c3aa1506148c101d71e288e436c62d18.tar.gz
speedup 'function is_port($port)' speed by skipping calls to getservbyname when possible
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc8
1 files changed, 3 insertions, 5 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 5c12697..1630b47 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -836,13 +836,11 @@ function is_validaliasname($name) {
/* returns true if $port is a valid TCP/UDP port */
function is_port($port) {
+ if (ctype_digit($port) && ((intval($port) >= 1) && (intval($port) <= 65535)))
+ return true;
if (getservbyname($port, "tcp") || getservbyname($port, "udp"))
return true;
- if (!ctype_digit($port))
- return false;
- else if ((intval($port) < 1) || (intval($port) > 65535))
- return false;
- return true;
+ return false;
}
/* returns true if $portrange is a valid TCP/UDP portrange ("<port>:<port>") */
OpenPOWER on IntegriCloud