Browse Source

optimized checkAppropriatePort

develop
ray-1337 3 years ago
parent
commit
f6f5dd36ff
  1. 11
      src/Util.js

11
src/Util.js

@ -72,16 +72,11 @@ module.exports.checkPlatformExact = async function () {
}; };
module.exports.checkAppropriatePort = function(port) { module.exports.checkAppropriatePort = function(port) {
if (typeof port !== "number") { const portLimit = Math.round(2 ** 16 - 1);
throw new Error("The port must be type of number.");
};
let portLimit = Math.round(2 ** 16 - 1); if (typeof port !== "number") throw new Error("The port must be type of number.");
if (port <= 0 || port > portLimit) {
throw new Error("Exceeded port limit.");
};
return true; return (port > 0 || port <= portLimit) ? true : false;
}; };
module.exports.checkAppropriateIP = function(address) { module.exports.checkAppropriateIP = function(address) {

Loading…
Cancel
Save