forked from svrjs/svrjs
Replace var's with let's and const's
This commit is contained in:
parent
3b4fd9641c
commit
979a30e938
13 changed files with 49 additions and 50 deletions
|
@ -29,8 +29,8 @@ function noproxyHandler(req, socket, head) {
|
||||||
// SVR.JS configuration object (modified)
|
// SVR.JS configuration object (modified)
|
||||||
const config = deepClone(process.serverConfig);
|
const config = deepClone(process.serverConfig);
|
||||||
|
|
||||||
var reqip = socket.remoteAddress;
|
const reqip = socket.remoteAddress;
|
||||||
var reqport = socket.remotePort;
|
const reqport = socket.remotePort;
|
||||||
process.reqcounter++;
|
process.reqcounter++;
|
||||||
logFacilities.locmessage(
|
logFacilities.locmessage(
|
||||||
`Somebody connected to ${
|
`Somebody connected to ${
|
||||||
|
|
|
@ -36,8 +36,8 @@ function proxyHandler(req, socket, head) {
|
||||||
return generateServerString(config.exposeServerVersion);
|
return generateServerString(config.exposeServerVersion);
|
||||||
};
|
};
|
||||||
|
|
||||||
var reqip = socket.remoteAddress;
|
const reqip = socket.remoteAddress;
|
||||||
var reqport = socket.remotePort;
|
const reqport = socket.remotePort;
|
||||||
process.reqcounter++;
|
process.reqcounter++;
|
||||||
logFacilities.locmessage(
|
logFacilities.locmessage(
|
||||||
`Somebody connected to ${
|
`Somebody connected to ${
|
||||||
|
|
37
src/index.js
37
src/index.js
|
@ -422,7 +422,7 @@ try {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ifaceEx = err;
|
ifaceEx = err;
|
||||||
}
|
}
|
||||||
var ips = [];
|
let ips = [];
|
||||||
const brdIPs = ["255.255.255.255", "127.255.255.255", "0.255.255.255"];
|
const brdIPs = ["255.255.255.255", "127.255.255.255", "0.255.255.255"];
|
||||||
const netIPs = ["127.0.0.0"];
|
const netIPs = ["127.0.0.0"];
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ if (ips.length == 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server IP address
|
// Server IP address
|
||||||
var host = ips[ips.length - 1];
|
let host = ips[ips.length - 1];
|
||||||
if (!host) host = "[offline]";
|
if (!host) host = "[offline]";
|
||||||
|
|
||||||
// Public IP address-related
|
// Public IP address-related
|
||||||
|
@ -1132,7 +1132,7 @@ if (process.serverConfig.secure) {
|
||||||
key: sniCredentialsSingle.key,
|
key: sniCredentialsSingle.key,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
var snMatches = sniCredentialsSingle.name.match(
|
let snMatches = sniCredentialsSingle.name.match(
|
||||||
/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/,
|
/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/,
|
||||||
);
|
);
|
||||||
if (!snMatches[1][0].match(/^\.+$/))
|
if (!snMatches[1][0].match(/^\.+$/))
|
||||||
|
@ -1414,7 +1414,7 @@ function SVRJSFork() {
|
||||||
"Starting next thread, because previous one hung up/crashed...",
|
"Starting next thread, because previous one hung up/crashed...",
|
||||||
);
|
);
|
||||||
// Fork new worker
|
// Fork new worker
|
||||||
var newWorker = {};
|
let newWorker = {};
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
!threadLimitWarned &&
|
!threadLimitWarned &&
|
||||||
|
@ -1518,7 +1518,7 @@ function getWorkerCountToFork() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function forkWorkers(workersToFork, callback) {
|
function forkWorkers(workersToFork, callback) {
|
||||||
for (var i = 0; i < workersToFork; i++) {
|
for (let i = 0; i < workersToFork; i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
SVRJSFork();
|
SVRJSFork();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1582,9 +1582,9 @@ function msgListener(message) {
|
||||||
|
|
||||||
// Save configuration file
|
// Save configuration file
|
||||||
function saveConfig() {
|
function saveConfig() {
|
||||||
for (var i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
try {
|
try {
|
||||||
var configJSONobj = {};
|
let configJSONobj = {};
|
||||||
if (fs.existsSync(process.dirname + "/config.json"))
|
if (fs.existsSync(process.dirname + "/config.json"))
|
||||||
configJSONobj = JSON.parse(
|
configJSONobj = JSON.parse(
|
||||||
fs.readFileSync(process.dirname + "/config.json").toString(),
|
fs.readFileSync(process.dirname + "/config.json").toString(),
|
||||||
|
@ -1674,12 +1674,11 @@ function saveConfig() {
|
||||||
if (configJSONobj.optOutOfStatisticsServer === undefined)
|
if (configJSONobj.optOutOfStatisticsServer === undefined)
|
||||||
configJSONobj.optOutOfStatisticsServer = false;
|
configJSONobj.optOutOfStatisticsServer = false;
|
||||||
|
|
||||||
var configString = JSON.stringify(configJSONobj, null, 2) + "\n";
|
fs.writeFileSync(__dirname + "/config.json", JSON.stringify(configJSONobj, null, 2) + "\n");
|
||||||
fs.writeFileSync(__dirname + "/config.json", configString);
|
|
||||||
break;
|
break;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (i >= 2) throw err;
|
if (i >= 2) throw err;
|
||||||
var now = Date.now();
|
const now = Date.now();
|
||||||
while (Date.now() - now < 2);
|
while (Date.now() - now < 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1967,8 +1966,8 @@ function start(init) {
|
||||||
}, 300000);
|
}, 300000);
|
||||||
} else if (cluster.isPrimary) {
|
} else if (cluster.isPrimary) {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
var allWorkers = Object.keys(cluster.workers);
|
let allWorkers = Object.keys(cluster.workers);
|
||||||
var goodWorkers = [];
|
let goodWorkers = [];
|
||||||
|
|
||||||
const checkWorker = (callback, _id) => {
|
const checkWorker = (callback, _id) => {
|
||||||
if (typeof _id === "undefined") _id = 0;
|
if (typeof _id === "undefined") _id = 0;
|
||||||
|
@ -2058,8 +2057,8 @@ function start(init) {
|
||||||
commands[line.split(" ")[0]] !== undefined &&
|
commands[line.split(" ")[0]] !== undefined &&
|
||||||
commands[line.split(" ")[0]] !== null
|
commands[line.split(" ")[0]] !== null
|
||||||
) {
|
) {
|
||||||
var argss = line.split(" ");
|
let argss = line.split(" ");
|
||||||
var command = argss.shift();
|
const command = argss.shift();
|
||||||
commands[command](argss, (msg) => process.send(msg));
|
commands[command](argss, (msg) => process.send(msg));
|
||||||
process.send("\x12END");
|
process.send("\x12END");
|
||||||
} else {
|
} else {
|
||||||
|
@ -2087,15 +2086,15 @@ function start(init) {
|
||||||
const command = argss.shift();
|
const command = argss.shift();
|
||||||
if (line != "") {
|
if (line != "") {
|
||||||
if (cluster.isPrimary !== undefined) {
|
if (cluster.isPrimary !== undefined) {
|
||||||
var allWorkers = Object.keys(cluster.workers);
|
let allWorkers = Object.keys(cluster.workers);
|
||||||
if (command == "block")
|
if (command == "block")
|
||||||
commands.block(argss, serverconsole.climessage);
|
commands.block(argss, serverconsole.climessage);
|
||||||
if (command == "unblock")
|
if (command == "unblock")
|
||||||
commands.unblock(argss, serverconsole.climessage);
|
commands.unblock(argss, serverconsole.climessage);
|
||||||
if (command == "restart") {
|
if (command == "restart") {
|
||||||
var stopError = false;
|
let stopError = false;
|
||||||
exiting = true;
|
exiting = true;
|
||||||
for (var i = 0; i < allWorkers.length; i++) {
|
for (let i = 0; i < allWorkers.length; i++) {
|
||||||
try {
|
try {
|
||||||
if (cluster.workers[allWorkers[i]]) {
|
if (cluster.workers[allWorkers[i]]) {
|
||||||
cluster.workers[allWorkers[i]].kill();
|
cluster.workers[allWorkers[i]].kill();
|
||||||
|
@ -2224,7 +2223,7 @@ function start(init) {
|
||||||
!process.serverConfig.secure
|
!process.serverConfig.secure
|
||||||
) {
|
) {
|
||||||
// It doesn't support through Unix sockets or Windows named pipes
|
// It doesn't support through Unix sockets or Windows named pipes
|
||||||
var address = (
|
let address = (
|
||||||
typeof process.serverConfig.port == "number" && listenAddress
|
typeof process.serverConfig.port == "number" && listenAddress
|
||||||
? listenAddress
|
? listenAddress
|
||||||
: "localhost"
|
: "localhost"
|
||||||
|
@ -2232,7 +2231,7 @@ function start(init) {
|
||||||
if (address.indexOf(":") > -1) {
|
if (address.indexOf(":") > -1) {
|
||||||
address = "[" + address + "]";
|
address = "[" + address + "]";
|
||||||
}
|
}
|
||||||
var connection = http2.connect(
|
const connection = http2.connect(
|
||||||
"http://" +
|
"http://" +
|
||||||
address +
|
address +
|
||||||
":" +
|
":" +
|
||||||
|
|
|
@ -29,7 +29,7 @@ let passwordHashCacheIntervalId = -1;
|
||||||
// Non-standard code object
|
// Non-standard code object
|
||||||
let nonStandardCodes = [];
|
let nonStandardCodes = [];
|
||||||
process.serverConfig.nonStandardCodes.forEach((nonStandardCodeRaw) => {
|
process.serverConfig.nonStandardCodes.forEach((nonStandardCodeRaw) => {
|
||||||
var newObject = {};
|
let newObject = {};
|
||||||
Object.keys(nonStandardCodeRaw).forEach((nsKey) => {
|
Object.keys(nonStandardCodeRaw).forEach((nsKey) => {
|
||||||
if (nsKey != "users") {
|
if (nsKey != "users") {
|
||||||
newObject[nsKey] = nonStandardCodeRaw[nsKey];
|
newObject[nsKey] = nonStandardCodeRaw[nsKey];
|
||||||
|
@ -77,7 +77,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
);
|
);
|
||||||
if (nonStandardCodes[i].regex) {
|
if (nonStandardCodes[i].regex) {
|
||||||
// Regex match
|
// Regex match
|
||||||
var createdRegex = createRegex(nonStandardCodes[i].regex, true);
|
const createdRegex = createRegex(nonStandardCodes[i].regex, true);
|
||||||
isMatch =
|
isMatch =
|
||||||
req.url.match(createdRegex) ||
|
req.url.match(createdRegex) ||
|
||||||
hrefWithoutDuplicateSlashes.match(createdRegex);
|
hrefWithoutDuplicateSlashes.match(createdRegex);
|
||||||
|
|
|
@ -9,7 +9,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
!config.disableNonEncryptedServer &&
|
!config.disableNonEncryptedServer &&
|
||||||
!config.disableToHTTPSRedirect
|
!config.disableToHTTPSRedirect
|
||||||
) {
|
) {
|
||||||
var hostx = req.headers.host;
|
const hostx = req.headers.host;
|
||||||
if (hostx === undefined) {
|
if (hostx === undefined) {
|
||||||
logFacilities.errmessage("Host header is missing.");
|
logFacilities.errmessage("Host header is missing.");
|
||||||
res.error(400);
|
res.error(400);
|
||||||
|
@ -22,7 +22,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPublicServer = !(
|
const isPublicServer = !(
|
||||||
req.socket.realRemoteAddress
|
req.socket.realRemoteAddress
|
||||||
? req.socket.realRemoteAddress
|
? req.socket.realRemoteAddress
|
||||||
: req.socket.remoteAddress
|
: req.socket.remoteAddress
|
||||||
|
@ -30,11 +30,11 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
/^(?:localhost$|::1$|f[c-d][0-9a-f]{2}:|(?:::ffff:)?(?:(?:127|10)\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3}|172\.(?:1[6-9]|2[0-9]|3[0-1])\.[0-9]{1,3}\.[0-9]{1,3})$)/i,
|
/^(?:localhost$|::1$|f[c-d][0-9a-f]{2}:|(?:::ffff:)?(?:(?:127|10)\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|192\.168\.[0-9]{1,3}\.[0-9]{1,3}|172\.(?:1[6-9]|2[0-9]|3[0-1])\.[0-9]{1,3}\.[0-9]{1,3})$)/i,
|
||||||
);
|
);
|
||||||
|
|
||||||
var destinationPort = 0;
|
let destinationPort = 0;
|
||||||
|
|
||||||
var parsedHostx = hostx.match(/(\[[^\]]*\]|[^:]*)(?::([0-9]+))?/);
|
const parsedHostx = hostx.match(/(\[[^\]]*\]|[^:]*)(?::([0-9]+))?/);
|
||||||
var hostname = parsedHostx[1];
|
let hostname = parsedHostx[1];
|
||||||
var hostPort = parsedHostx[2] ? parseInt(parsedHostx[2]) : 80;
|
let hostPort = parsedHostx[2] ? parseInt(parsedHostx[2]) : 80;
|
||||||
if (isNaN(hostPort)) hostPort = 80;
|
if (isNaN(hostPort)) hostPort = 80;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = (req, res, logFacilities, config, next) => {
|
module.exports = (req, res, logFacilities, config, next) => {
|
||||||
if (!req.isProxy) {
|
if (!req.isProxy) {
|
||||||
var hkh = config.getCustomHeaders();
|
const hkh = config.getCustomHeaders();
|
||||||
Object.keys(hkh).forEach((hkS) => {
|
Object.keys(hkh).forEach((hkS) => {
|
||||||
try {
|
try {
|
||||||
res.setHeader(hkS, hkh[hkS]);
|
res.setHeader(hkS, hkh[hkS]);
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
fs.stat(
|
fs.stat(
|
||||||
"." + decodeURIComponent(req.parsedURL.pathname),
|
"." + decodeURIComponent(req.parsedURL.pathname),
|
||||||
(err, stats) => {
|
(err, stats) => {
|
||||||
var _fileState = 3;
|
let _fileState = 3;
|
||||||
if (err) {
|
if (err) {
|
||||||
_fileState = 3;
|
_fileState = 3;
|
||||||
} else if (stats.isDirectory()) {
|
} else if (stats.isDirectory()) {
|
||||||
|
@ -126,7 +126,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
logFacilities.errmessage("Content blocked.");
|
logFacilities.errmessage("Content blocked.");
|
||||||
return;
|
return;
|
||||||
} else if (sHref != req.parsedURL.pathname) {
|
} else if (sHref != req.parsedURL.pathname) {
|
||||||
var rewrittenAgainURL =
|
const rewrittenAgainURL =
|
||||||
sHref +
|
sHref +
|
||||||
(req.parsedURL.search ? req.parsedURL.search : "") +
|
(req.parsedURL.search ? req.parsedURL.search : "") +
|
||||||
(req.parsedURL.hash ? req.parsedURL.hash : "");
|
(req.parsedURL.hash ? req.parsedURL.hash : "");
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
let levelDownCount = 0;
|
let levelDownCount = 0;
|
||||||
|
|
||||||
// Loop through the path components
|
// Loop through the path components
|
||||||
for (var i = 0; i < pathComponents.length; i++) {
|
for (let i = 0; i < pathComponents.length; i++) {
|
||||||
// If the component is "..", decrement the levelUpCount
|
// If the component is "..", decrement the levelUpCount
|
||||||
if (".." === pathComponents[i]) {
|
if (".." === pathComponents[i]) {
|
||||||
levelUpCount--;
|
levelUpCount--;
|
||||||
|
@ -313,7 +313,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
// Helper function to check if compression is allowed for the file
|
// Helper function to check if compression is allowed for the file
|
||||||
const canCompress = (path, list) => {
|
const canCompress = (path, list) => {
|
||||||
let canCompress = true;
|
let canCompress = true;
|
||||||
for (var i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
if (createRegex(list[i], true).test(path)) {
|
if (createRegex(list[i], true).test(path)) {
|
||||||
canCompress = false;
|
canCompress = false;
|
||||||
break;
|
break;
|
||||||
|
@ -437,7 +437,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
})
|
})
|
||||||
.on("open", () => {
|
.on("open", () => {
|
||||||
try {
|
try {
|
||||||
var resStream = {};
|
let resStream = {};
|
||||||
if (useBrotli && isCompressable) {
|
if (useBrotli && isCompressable) {
|
||||||
resStream = zlib.createBrotliCompress();
|
resStream = zlib.createBrotliCompress();
|
||||||
resStream.pipe(res);
|
resStream.pipe(res);
|
||||||
|
@ -738,7 +738,7 @@ module.exports = (req, res, logFacilities, config, next) => {
|
||||||
// Get stats for all files in the directory and generate the listing
|
// Get stats for all files in the directory and generate the listing
|
||||||
getStatsForAllFiles(list, readFrom, (filelist) => {
|
getStatsForAllFiles(list, readFrom, (filelist) => {
|
||||||
let directoryListingRows = [];
|
let directoryListingRows = [];
|
||||||
for (var i = 0; i < filelist.length; i++) {
|
for (let i = 0; i < filelist.length; i++) {
|
||||||
if (filelist[i].name[0] !== ".") {
|
if (filelist[i].name[0] !== ".") {
|
||||||
const estats = filelist[i].stats;
|
const estats = filelist[i].stats;
|
||||||
const ename = filelist[i].name;
|
const ename = filelist[i].name;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Generate V8-style error stack from Error object.
|
// Generate V8-style error stack from Error object.
|
||||||
function generateErrorStack(errorObject) {
|
function generateErrorStack(errorObject) {
|
||||||
// Split the error stack by newlines.
|
// Split the error stack by newlines.
|
||||||
var errorStack = errorObject.stack ? errorObject.stack.split("\n") : [];
|
const errorStack = errorObject.stack ? errorObject.stack.split("\n") : [];
|
||||||
|
|
||||||
// If the error stack starts with the error name, return the original stack (it is V8-style then).
|
// If the error stack starts with the error name, return the original stack (it is V8-style then).
|
||||||
if (
|
if (
|
||||||
|
@ -13,7 +13,7 @@ function generateErrorStack(errorObject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new error stack with the error name and code (if available).
|
// Create a new error stack with the error name and code (if available).
|
||||||
var newErrorStack = [
|
let newErrorStack = [
|
||||||
errorObject.name +
|
errorObject.name +
|
||||||
(errorObject.code ? ": " + errorObject.code : "") +
|
(errorObject.code ? ": " + errorObject.code : "") +
|
||||||
(errorObject.message == "" ? "" : ": " + errorObject.message),
|
(errorObject.message == "" ? "" : ": " + errorObject.message),
|
||||||
|
@ -23,12 +23,12 @@ function generateErrorStack(errorObject) {
|
||||||
errorStack.forEach((errorStackLine) => {
|
errorStack.forEach((errorStackLine) => {
|
||||||
if (errorStackLine != "") {
|
if (errorStackLine != "") {
|
||||||
// Split the line into function and location parts (if available).
|
// Split the line into function and location parts (if available).
|
||||||
var errorFrame = errorStackLine.split("@");
|
let errorFrame = errorStackLine.split("@");
|
||||||
var location = "";
|
let location = "";
|
||||||
if (errorFrame.length > 1 && errorFrame[0] == "global code")
|
if (errorFrame.length > 1 && errorFrame[0] == "global code")
|
||||||
errorFrame.shift();
|
errorFrame.shift();
|
||||||
if (errorFrame.length > 1) location = errorFrame.pop();
|
if (errorFrame.length > 1) location = errorFrame.pop();
|
||||||
var func = errorFrame.join("@");
|
const func = errorFrame.join("@");
|
||||||
|
|
||||||
// Build the new error stack entry with function and location information.
|
// Build the new error stack entry with function and location information.
|
||||||
newErrorStack.push(
|
newErrorStack.push(
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
|
|
||||||
function getOS() {
|
function getOS() {
|
||||||
var osType = os.type();
|
const osType = os.type();
|
||||||
var platform = os.platform();
|
const platform = os.platform();
|
||||||
if (platform == "android") {
|
if (platform == "android") {
|
||||||
return "Android";
|
return "Android";
|
||||||
} else if (osType == "Windows_NT" || osType == "WindowsNT") {
|
} else if (osType == "Windows_NT" || osType == "WindowsNT") {
|
||||||
var arch = os.arch();
|
const arch = os.arch();
|
||||||
if (arch == "ia32") {
|
if (arch == "ia32") {
|
||||||
return "Win32";
|
return "Win32";
|
||||||
} else if (arch == "x64") {
|
} else if (arch == "x64") {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
function ipBlockList(rawBlockList) {
|
function ipBlockList(rawBlockList) {
|
||||||
// Initialize the instance with empty arrays
|
// Initialize the instance with empty arrays
|
||||||
if (rawBlockList === undefined) rawBlockList = [];
|
if (rawBlockList === undefined) rawBlockList = [];
|
||||||
var instance = {
|
const instance = {
|
||||||
raw: [],
|
raw: [],
|
||||||
rawtoPreparedMap: [],
|
rawtoPreparedMap: [],
|
||||||
prepared: [],
|
prepared: [],
|
||||||
|
|
|
@ -14,7 +14,7 @@ function calculateBroadcastIPv4FromCidr(ipWithCidr) {
|
||||||
.split(".")
|
.split(".")
|
||||||
.map((num, index) => {
|
.map((num, index) => {
|
||||||
// Calculate resulting 8-bit
|
// Calculate resulting 8-bit
|
||||||
var power = Math.max(Math.min(mask - index * 8, 8), 0);
|
const power = Math.max(Math.min(mask - index * 8, 8), 0);
|
||||||
return (
|
return (
|
||||||
(parseInt(num) & ((Math.pow(2, power) - 1) << (8 - power))) |
|
(parseInt(num) & ((Math.pow(2, power) - 1) << (8 - power))) |
|
||||||
(Math.pow(2, 8 - power) - 1)
|
(Math.pow(2, 8 - power) - 1)
|
||||||
|
@ -39,7 +39,7 @@ function calculateNetworkIPv4FromCidr(ipWithCidr) {
|
||||||
.split(".")
|
.split(".")
|
||||||
.map((num, index) => {
|
.map((num, index) => {
|
||||||
// Calculate resulting 8-bit
|
// Calculate resulting 8-bit
|
||||||
var power = Math.max(Math.min(mask - index * 8, 8), 0);
|
const power = Math.max(Math.min(mask - index * 8, 8), 0);
|
||||||
return (
|
return (
|
||||||
parseInt(num) &
|
parseInt(num) &
|
||||||
((Math.pow(2, power) - 1) << (8 - power))
|
((Math.pow(2, power) - 1) << (8 - power))
|
||||||
|
|
|
@ -78,7 +78,7 @@ function LOG(s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server console function
|
// Server console function
|
||||||
var serverconsole = {
|
const serverconsole = {
|
||||||
climessage: (msg, reqId) => {
|
climessage: (msg, reqId) => {
|
||||||
if (msg.indexOf("\n") != -1) {
|
if (msg.indexOf("\n") != -1) {
|
||||||
msg.split("\n").forEach((nmsg) => {
|
msg.split("\n").forEach((nmsg) => {
|
||||||
|
|
Reference in a new issue