more optimizations, remove WTVIRC for now, upgrade test.js
This commit is contained in:
@@ -9,7 +9,7 @@ if (auth === true) {
|
||||
const authheader = request_headers.authorization.split(' ');
|
||||
console.log(request_headers)
|
||||
|
||||
if (authheader[0] == "Basic") {
|
||||
if (authheader[0] === "Basic") {
|
||||
password = Buffer.from(authheader[1], 'base64').toString();
|
||||
password = password.split(':')[1];
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ if (auth === true) {
|
||||
const authheader = request_headers.authorization.split(' ');
|
||||
console.log(request_headers)
|
||||
|
||||
if (authheader[0] == "Basic") {
|
||||
if (authheader[0] === "Basic") {
|
||||
let password = Buffer.from(authheader[1], 'base64').toString();
|
||||
password = password.split(':')[1];
|
||||
}
|
||||
@@ -29,7 +29,7 @@ Content-Type: text/html`
|
||||
Welcome to the zefie minisrv v${minisrv_config.version} Account Administration
|
||||
</p>
|
||||
`;
|
||||
if (request_headers.query.cmd == "list") {
|
||||
if (request_headers.query.cmd === "list") {
|
||||
data += `<hr>`;
|
||||
if (request_headers.query.msg) {
|
||||
data += decodeURI(request_headers.query.msg) + "<hr>";
|
||||
@@ -41,7 +41,7 @@ Welcome to the zefie minisrv v${minisrv_config.version} Account Administration
|
||||
});
|
||||
data += `</table>`;
|
||||
|
||||
} else if (request_headers.query.cmd == "ssid") {
|
||||
} else if (request_headers.query.cmd === "ssid") {
|
||||
const ssid = request_headers.query.ssid;
|
||||
if (!ssid) {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
@@ -78,7 +78,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
if (Object.keys(user_info.account_users).length > 1) {
|
||||
data += `<tr><td style="vertical-align: top">Additional Users:</td><td>`;
|
||||
Object.keys(user_info.account_users).forEach(function (k) {
|
||||
if (k == "subscriber") return;
|
||||
if (k === "subscriber") return;
|
||||
data += user_info.account_users[k].subscriber_username + "<br>";
|
||||
})
|
||||
data += `</td></tr>`
|
||||
@@ -91,7 +91,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
data += "The SSID does not exist in the SessionStore."
|
||||
}
|
||||
}
|
||||
} else if (request_headers.query.cmd == "delete") {
|
||||
} else if (request_headers.query.cmd === "delete") {
|
||||
redirectmsg = "";
|
||||
const ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
@@ -102,7 +102,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=list&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "ban") {
|
||||
} else if (request_headers.query.cmd === "ban") {
|
||||
redirectmsg = "";
|
||||
const ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
@@ -110,7 +110,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
if (result === wtva.SUCCESS) {
|
||||
reloadConfig();
|
||||
redirectmsg = "The SSID is now banned.";
|
||||
} else if (result == wtva.REASON_EXISTS) {
|
||||
} else if (result === wtva.REASON_EXISTS) {
|
||||
redirectmsg = "The SSID was already banned.";
|
||||
} else {
|
||||
redirectmsg = "Unknown response " + result.toString();
|
||||
@@ -119,7 +119,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
redirectmsg = `An SSID is required for the ${request_headers.query.cmd} command.`;
|
||||
}
|
||||
headers = "302 OK\nLocation: /admin/?cmd=ssid&ssid=" + encodeURI(ssid) + "&msg=" + encodeURI(redirectmsg);
|
||||
} else if (request_headers.query.cmd == "unban") {
|
||||
} else if (request_headers.query.cmd === "unban") {
|
||||
redirectmsg = "The SSID was not banned, so it could not be unbanned.";
|
||||
const ssid = request_headers.query.ssid;
|
||||
if (ssid) {
|
||||
@@ -127,7 +127,7 @@ function validateSelection(cmd, ssid, friendlymsg) {
|
||||
if (result === wtva.SUCCESS) {
|
||||
reloadConfig();
|
||||
redirectmsg = "The SSID is now unbanned.";
|
||||
} else if (result == wtva.REASON_EXISTS) {
|
||||
} else if (result === wtva.REASON_EXISTS) {
|
||||
redirectmsg = "The SSID was not banned.";
|
||||
} else {
|
||||
redirectmsg = "Unknown response " + result.toString();
|
||||
|
||||
@@ -74,7 +74,7 @@ const patch_limits = {
|
||||
|
||||
function getPatchDataType(type, invert = false) {
|
||||
let patch_data = false;
|
||||
if ((type == "wtv-incarnation" && !invert) || (type == "wtv-encryption" && invert)) {
|
||||
if ((type === "wtv-incarnation" && !invert) || (type === "wtv-encryption" && invert)) {
|
||||
patch_data = "wtv-client-serial-number: %s\r\n"
|
||||
patch_data += "wtv-user-requested-upgrade: %s\r\n";
|
||||
patch_data += "wtv-system-cpuprid: %s\r\n";
|
||||
@@ -87,7 +87,7 @@ function getPatchDataType(type, invert = false) {
|
||||
patch_data += "wtv-system-chipversion: %s\r\n";
|
||||
patch_data += "User-Agent: %s\r\n";
|
||||
}
|
||||
else if ((type == "wtv-encryption" && !invert) || (type == "wtv-incarnation" && invert) ) {
|
||||
else if ((type === "wtv-encryption" && !invert) || (type === "wtv-incarnation" && invert) ) {
|
||||
patch_data = "wtv-tourist-enabled: %s\r\n";
|
||||
patch_data += "wtv-demo-enabled: %s\r\n";
|
||||
patch_data += "wtv-default-client-scriptprops: %s\r\n";
|
||||
@@ -106,7 +106,7 @@ function getPatchDataType(type, invert = false) {
|
||||
|
||||
function getResData(file) {
|
||||
let res_data = null;
|
||||
if (file.slice(-2, 2).toLowerCase() == "gz") {
|
||||
if (file.slice(-2, 2).toLowerCase() === "gz") {
|
||||
const res_gz_data = wtvshared.getServiceDep("/viewergen/" + file);
|
||||
res_data = zlib.gunzipSync(res_gz_data);
|
||||
} else {
|
||||
@@ -227,14 +227,14 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def
|
||||
const val = customized_patch_data[idx];
|
||||
if (typeof val === 'string') {
|
||||
// start url override
|
||||
if (start_url != patch_defaults.start_url && start_url.length <= patch_limits.start_url) {
|
||||
if (val.slice(0, patch_defaults.start_url.length) == patch_defaults.start_url)
|
||||
if (start_url !== patch_defaults.start_url && start_url.length <= patch_limits.start_url) {
|
||||
if (val.slice(0, patch_defaults.start_url.length) === patch_defaults.start_url)
|
||||
customized_patch_data[idx] = start_url + "\x00";
|
||||
}
|
||||
|
||||
// default service ip override
|
||||
if (default_ip != patch_defaults.default_ip && default_ip.length <= patch_limits.default_ip) {
|
||||
if (val.slice(0, patch_defaults.default_ip.length) == patch_defaults.default_ip)
|
||||
if (default_ip !== patch_defaults.default_ip && default_ip.length <= patch_limits.default_ip) {
|
||||
if (val.slice(0, patch_defaults.default_ip.length) === patch_defaults.default_ip)
|
||||
customized_patch_data[idx] = default_ip + "\x00";
|
||||
}
|
||||
} else {
|
||||
@@ -242,7 +242,7 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def
|
||||
// not a buffer object
|
||||
let patch_data_string = "";
|
||||
const block_length = val['length'];
|
||||
const patch_data = getPatchDataType(val['type'], (fname.slice(12, 3) != "1.1"));
|
||||
const patch_data = getPatchDataType(val['type'], (fname.slice(12, 3) !== "1.1"));
|
||||
if (patch_data) {
|
||||
const patch_data_array = patch_data.split("\r\n");
|
||||
|
||||
@@ -256,7 +256,7 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def
|
||||
}
|
||||
});
|
||||
}
|
||||
if (fname.slice(12, 3) != "2.5") {
|
||||
if (fname.slice(12, 3) !== "2.5") {
|
||||
const length_difference = block_length - patch_data_string.length;
|
||||
if (length_difference > 0)
|
||||
patch_data_string += "\x00".repeat(length_difference - (val['type'].length + 1));
|
||||
@@ -292,7 +292,7 @@ function patchBinary(patchDataObject) {
|
||||
function generateSSID() {
|
||||
const ssid_template = "91xxxxxxaeb002";
|
||||
let ssid = ssid_template;
|
||||
while (ssid.indexOf("x") != -1) {
|
||||
while (ssid.indexOf("x") !== -1) {
|
||||
// random hex char from 0-F
|
||||
ssid = ssid.replace("x", Math.floor(Math.random() * 16).toString(16))
|
||||
}
|
||||
@@ -458,7 +458,7 @@ if (request_headers.query.viewer &&
|
||||
const viewer_gz_data = wtvshared.getServiceDep("/viewergen/" + viewer_file + ".gz");
|
||||
const viewer_data = zlib.gunzipSync(viewer_gz_data);
|
||||
const viewer_md5 = crypto.createHash('md5').update(viewer_data).digest("hex");
|
||||
if (viewer_md5 != viewer_stock_md5s[viewer_file]) {
|
||||
if (viewer_md5 !== viewer_stock_md5s[viewer_file]) {
|
||||
console.error(viewer_file, "md5sum error. expected:", viewer_stock_md5s[viewer_file], ", got:", viewer_md5)
|
||||
const errpage = wtvshared.doErrorPage("500", null, socket.minisrv_pc_mode)
|
||||
headers = errpage[0];
|
||||
@@ -514,7 +514,7 @@ Content-Disposition: attachment; filename="${viewer_file.replace(".exe", ".zip")
|
||||
console.log(request_headers)
|
||||
let update_str = "http://" + request_headers.host + request_headers.request_url.split('?')[0] + "?ssid=" + client_ssid;
|
||||
Object.keys(request_headers.query).forEach((k) => {
|
||||
if (k != "random_ssid") {
|
||||
if (k !== "random_ssid") {
|
||||
update_str += "&" + encodeURIComponent(k) + "=" + encodeURIComponent(request_headers.query[k]);
|
||||
}
|
||||
});
|
||||
@@ -525,7 +525,7 @@ Content-Disposition: attachment; filename="${viewer_file.replace(".exe", ".zip")
|
||||
const romset_zip = new AdmZip(wtvshared.getServiceDep("/viewergen/" + viewer_file.replace(".exe", "").replace("WebTVIntel", "AppData") + ".zip", true));
|
||||
const zipEntries = romset_zip.getEntries();
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
if (zipEntry.entryName == "Setup.bmp" && request_headers.query.logo) {
|
||||
if (zipEntry.entryName === "Setup.bmp" && request_headers.query.logo) {
|
||||
const logo_file = logos[parseInt(request_headers.query.logo) || 0];
|
||||
if (logo_file) {
|
||||
const logo_gz_data = wtvshared.getServiceDep("/viewergen/" + logo_file + ".gz");
|
||||
|
||||
Reference in New Issue
Block a user