diff --git a/src/Util.js b/src/Util.js index 2bbc5dc..44dbd41 100644 --- a/src/Util.js +++ b/src/Util.js @@ -75,6 +75,19 @@ module.exports.checkPlatformExact = function () { return true; }; +module.exports.checkAppropriatePort = function(port) { + if (typeof port !== "number") { + throw new Error("The port must be type of number."); + }; + + let portLimit = Math.round(2 ** 16 - 1); + if (port <= 0 || port > portLimit) { + throw new Error("Exceeded port limit."); + }; + + return true; +}; + // soon to be continued // module.exports.checkPlatformVersion = function () { // let distroInfo = this.getDistroInfo();