fix/optimize wtv-flashrom, wtv-disk, wtv-guide
This commit is contained in:
@@ -1,27 +1,27 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
//GET wtv-disk:/content/DownloadScreen.tmpl?diskmap=Demo&group=Demo
|
//GET wtv-disk:/content/DownloadScreen.tmpl?diskmap=Demo&group=Demo
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
wtv-expire: wtv-disk:/content/DownloadScreen.tmpl`
|
wtv-expire: wtv-disk:/content/DownloadScreen.tmpl`
|
||||||
var content_dir = "content/"
|
const content_dir = "content/"
|
||||||
var diskmap_dir = content_dir + "diskmaps/";
|
const diskmap_dir = content_dir + "diskmaps/";
|
||||||
var diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
const diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
||||||
var diskmap_json_file = null;
|
let diskmap_json_file = null;
|
||||||
Object.keys(service_vaults).forEach(function (g) {
|
Object.keys(service_vaults).forEach(function (g) {
|
||||||
if (diskmap_json_file != null) return;
|
if (diskmap_json_file != null) return;
|
||||||
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||||
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null;
|
||||||
});
|
});
|
||||||
var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
let diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||||
if (!diskmap_data[request_headers.query.group]) {
|
if (!diskmap_data[request_headers.query.group]) {
|
||||||
throw ("Invalid diskmap data (group does not match)");
|
throw ("Invalid diskmap data (group does not match)");
|
||||||
}
|
}
|
||||||
diskmap_data = diskmap_data[request_headers.query.group];
|
diskmap_data = diskmap_data[request_headers.query.group];
|
||||||
var message = request_headers.query.message || diskmap_data.message || "Retrieving files...";
|
const message = request_headers.query.message || diskmap_data.message || "Retrieving files...";
|
||||||
var main_message = request_headers.query.main_message || diskmap_data.main_message || "Your receiver is downloading files.";
|
const main_message = request_headers.query.main_message || diskmap_data.main_message || "Your receiver is downloading files.";
|
||||||
var success_url = request_headers.query.success_url || diskmap_data.success_url || null;
|
let success_url = request_headers.query.success_url || diskmap_data.success_url || null;
|
||||||
var fail_url = request_headers.query.fail_url || diskmap_data.fail_url || null;
|
let fail_url = request_headers.query.fail_url || diskmap_data.fail_url || null;
|
||||||
|
|
||||||
if (success_url === null) success_url = new clientShowAlert({
|
if (success_url === null) success_url = new clientShowAlert({
|
||||||
'image': this.minisrv_config.config.service_logo,
|
'image': this.minisrv_config.config.service_logo,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-Type: text/html`;
|
Content-Type: text/html`;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
const diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)];
|
||||||
var wtvdl = new WTVDisk(minisrv_config, service_name);
|
const wtvdl = new WTVDisk(minisrv_config, service_name);
|
||||||
|
|
||||||
var force_update = (request_headers.query.force == "true") ? true : false;
|
const force_update = (request_headers.query.force == "true") ? true : false;
|
||||||
var no_delete = (request_headers.query.dont_delete_files == "true") ? true : false;
|
const no_delete = (request_headers.query.dont_delete_files == "true") ? true : false;
|
||||||
var content_dir = "content/"
|
const content_dir = "content/"
|
||||||
var diskmap_dir = content_dir + "diskmaps/";
|
const diskmap_dir = content_dir + "diskmaps/";
|
||||||
|
|
||||||
if (request_headers['wtv-request-type'] == 'download') {
|
if (request_headers['wtv-request-type'] == 'download') {
|
||||||
|
|
||||||
function generateDownloadList(diskmap_group_name, update_list, diskmap_group_data) {
|
function generateDownloadList(diskmap_group_name, update_list, diskmap_group_data) {
|
||||||
wtvdl.reset();
|
wtvdl.reset();
|
||||||
var files_to_send = 0;
|
let files_to_send = 0;
|
||||||
Object.keys(update_list).forEach(function (k) {
|
Object.keys(update_list).forEach(function (k) {
|
||||||
if (update_list[k].checksum_match && !force_update) return;
|
if (update_list[k].checksum_match && !force_update) return;
|
||||||
if (!update_list[k].invalid && !force_update) return;
|
if (!update_list[k].invalid && !force_update) return;
|
||||||
@@ -65,7 +65,7 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
if (update_list[k].checksum_match && !force_update) return;
|
if (update_list[k].checksum_match && !force_update) return;
|
||||||
if (!update_list[k].invalid && !force_update) return;
|
if (!update_list[k].invalid && !force_update) return;
|
||||||
}
|
}
|
||||||
delete_file = update_list[k].file.replace(diskmap_group_data.base, "")
|
let delete_file = update_list[k].file.replace(diskmap_group_data.base, "")
|
||||||
if (!diskmap_group_data.files[k].dont_extract_filename) {
|
if (!diskmap_group_data.files[k].dont_extract_filename) {
|
||||||
delete_file = delete_file.replace(".gz","");
|
delete_file = delete_file.replace(".gz","");
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "GET":
|
case "GET":
|
||||||
var get_url = service_name + ":/" + update_list[k].location + "?";
|
let get_url = service_name + ":/" + update_list[k].location + "?";
|
||||||
if (update_list[k].compress === false) get_url += "dont_compress=true&";
|
if (update_list[k].compress === false) get_url += "dont_compress=true&";
|
||||||
if (update_list[k].type) get_url += "content_type=" + encodeURIComponent(update_list[k].type) + "&";
|
if (update_list[k].type) get_url += "content_type=" + encodeURIComponent(update_list[k].type) + "&";
|
||||||
wtvdl.get(update_list[k].file.replace(diskmap_group_data.base, ""), update_list[k].file, get_url, diskmap_group_name, update_list[k].checksum, update_list[k].uncompressed_size || null, update_list[k].original_filename)
|
wtvdl.get(update_list[k].file.replace(diskmap_group_data.base, ""), update_list[k].file, get_url, diskmap_group_name, update_list[k].checksum, update_list[k].uncompressed_size || null, update_list[k].original_filename)
|
||||||
@@ -116,33 +116,33 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
wtvdl.deleteGroupUpdate(diskmap_group_name, diskmap_group_data.base);
|
wtvdl.deleteGroupUpdate(diskmap_group_name, diskmap_group_data.base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var download_list = wtvdl.getDownloadList();
|
const download_list = wtvdl.getDownloadList();
|
||||||
if (minisrv_config.config.show_diskmap) console.log(download_list);
|
if (minisrv_config.config.show_diskmap) console.log(download_list);
|
||||||
return download_list;
|
return download_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processGroup(diskmap_primary_group, diskmap_group_data, diskmap_subgroup = null, version = 0) {
|
function processGroup(diskmap_primary_group, diskmap_group_data, diskmap_subgroup = null, version = 0) {
|
||||||
// parse webtv post
|
// parse webtv post
|
||||||
var output_data = '';
|
let output_data = '';
|
||||||
var post_data = [];
|
let post_data = [];
|
||||||
var client_group_data = [];
|
let client_group_data = [];
|
||||||
if (request_headers.post_data) {
|
if (request_headers.post_data) {
|
||||||
post_data = request_headers.post_data.toString(CryptoJS.enc.Latin1).split("\n");
|
post_data = request_headers.post_data.toString(CryptoJS.enc.Latin1).split("\n");
|
||||||
client_group_data = wtvdl.getGroupDataFromClientPost(request_headers.post_data.toString(CryptoJS.enc.Latin1));
|
client_group_data = wtvdl.getGroupDataFromClientPost(request_headers.post_data.toString(CryptoJS.enc.Latin1));
|
||||||
}
|
}
|
||||||
var post_data_current_directory = '';
|
let post_data_current_directory = '';
|
||||||
var post_data_current_file = false;
|
let post_data_current_file = false;
|
||||||
var post_data_current_group = '';
|
let post_data_current_group = '';
|
||||||
var post_data_last_modified = false;
|
let post_data_last_modified = false;
|
||||||
var post_data_content_length = false;
|
let post_data_content_length = false;
|
||||||
var post_data_current_group_state = false;
|
let post_data_current_group_state = false;
|
||||||
var post_data_fileinfo = [];
|
const post_data_fileinfo = [];
|
||||||
var entry_type = false;
|
let entry_type = false;
|
||||||
var post_data_current_version = false;
|
let post_data_current_version = false;
|
||||||
var post_data_current_checksum = false;
|
let post_data_current_checksum = false;
|
||||||
var post_data_last_checkup_time = 0;
|
let post_data_last_checkup_time = 0;
|
||||||
Object.keys(post_data).forEach(function (k) {
|
Object.keys(post_data).forEach(function (k) {
|
||||||
if (post_data[k].substring(0, 7) == "file://") {
|
if (post_data[k].slice(0, 7) == "file://") {
|
||||||
entry_type = "folder";
|
entry_type = "folder";
|
||||||
post_data_current_file = false;
|
post_data_current_file = false;
|
||||||
post_data_current_version = false;
|
post_data_current_version = false;
|
||||||
@@ -155,10 +155,10 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
post_data_current_directory = post_data[k];
|
post_data_current_directory = post_data[k];
|
||||||
} else {
|
} else {
|
||||||
if (post_data[k].indexOf(":") > 0) {
|
if (post_data[k].indexOf(":") > 0) {
|
||||||
var post_data_line = post_data[k].split(": ")
|
const post_data_line = post_data[k].split(": ")
|
||||||
var post_data_line_name = post_data_line[0];
|
const post_data_line_name = post_data_line[0];
|
||||||
post_data_line.shift();
|
post_data_line.shift();
|
||||||
var post_data_line_data = post_data_line.join(": ");
|
const post_data_line_data = post_data_line.join(": ");
|
||||||
|
|
||||||
switch (post_data_line_name.toLowerCase()) {
|
switch (post_data_line_name.toLowerCase()) {
|
||||||
case "last-modified":
|
case "last-modified":
|
||||||
@@ -190,8 +190,8 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (post_data[k] == "" && entry_type) {
|
if (post_data[k] == "" && entry_type) {
|
||||||
var post_data_current_path = ((entry_type == "file") ? (post_data_current_directory + post_data_current_file) : post_data_current_directory);
|
const post_data_current_path = ((entry_type == "file") ? (post_data_current_directory + post_data_current_file) : post_data_current_directory);
|
||||||
var index = post_data_current_path.replace(/[\:\/]/g, "_").toLowerCase() + "_" + post_data_current_group;
|
const index = post_data_current_path.replace(/[\:\/]/g, "_").toLowerCase() + "_" + post_data_current_group;
|
||||||
if (index.match(/\/$/)) entry_type = "folder";
|
if (index.match(/\/$/)) entry_type = "folder";
|
||||||
if (!post_data_fileinfo[index]) post_data_fileinfo[index] = {};
|
if (!post_data_fileinfo[index]) post_data_fileinfo[index] = {};
|
||||||
post_data_fileinfo[index].entry_type = entry_type;
|
post_data_fileinfo[index].entry_type = entry_type;
|
||||||
@@ -208,11 +208,11 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var wtv_download_list = [];
|
const wtv_download_list = [];
|
||||||
var newest_file_epoch = version;
|
let newest_file_epoch = version;
|
||||||
Object.keys(diskmap_group_data.files).forEach(function (k) {
|
Object.keys(diskmap_group_data.files).forEach(function (k) {
|
||||||
if (!diskmap_group_data.files[k].location) diskmap_group_data.files[k].location = wtvshared.makeSafePath(diskmap_group_data.location,diskmap_group_data.files[k].file.replace(diskmap_group_data.base, ""), true);
|
if (!diskmap_group_data.files[k].location) diskmap_group_data.files[k].location = wtvshared.makeSafePath(diskmap_group_data.location,diskmap_group_data.files[k].file.replace(diskmap_group_data.base, ""), true);
|
||||||
var diskmap_data_file = null;
|
let diskmap_data_file = null;
|
||||||
Object.keys(service_vaults).forEach(function (g) {
|
Object.keys(service_vaults).forEach(function (g) {
|
||||||
if (diskmap_data_file != null) return;
|
if (diskmap_data_file != null) return;
|
||||||
diskmap_data_file = service_vaults[g] + "/" + service_name + "/" + diskmap_group_data.files[k].location;
|
diskmap_data_file = service_vaults[g] + "/" + service_name + "/" + diskmap_group_data.files[k].location;
|
||||||
@@ -220,8 +220,8 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (diskmap_data_file) {
|
if (diskmap_data_file) {
|
||||||
var diskmap_file_stat = fs.lstatSync(diskmap_data_file);
|
const diskmap_file_stat = fs.lstatSync(diskmap_data_file);
|
||||||
var diskmap_file_data = Buffer.from(fs.readFileSync(diskmap_data_file, {
|
const diskmap_file_data = Buffer.from(fs.readFileSync(diskmap_data_file, {
|
||||||
encoding: null,
|
encoding: null,
|
||||||
flags: 'r'
|
flags: 'r'
|
||||||
}));
|
}));
|
||||||
@@ -232,15 +232,14 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
|
|
||||||
// we need the checksum of the uncompressed data
|
// we need the checksum of the uncompressed data
|
||||||
if (wtvshared.getFileExt(diskmap_data_file).toLowerCase() == "gz") {
|
if (wtvshared.getFileExt(diskmap_data_file).toLowerCase() == "gz") {
|
||||||
var diskmap_data_filename = path.basename(diskmap_data_file);
|
const diskmap_data_filename = path.basename(diskmap_data_file);
|
||||||
var gunzipped = zlib.gunzipSync(diskmap_file_data);
|
const gunzipped = zlib.gunzipSync(diskmap_file_data);
|
||||||
diskmap_group_data.files[k].checksum = CryptoJS.MD5(CryptoJS.lib.WordArray.create(gunzipped)).toString(CryptoJS.enc.Hex).toLowerCase();
|
diskmap_group_data.files[k].checksum = CryptoJS.MD5(CryptoJS.lib.WordArray.create(gunzipped)).toString(CryptoJS.enc.Hex).toLowerCase();
|
||||||
var gzip_fn_end = diskmap_file_data.indexOf("\0", 10);
|
const gzip_fn_end = diskmap_file_data.indexOf("\0", 10);
|
||||||
if (!diskmap_group_data.files[k].dont_extract_filename) {
|
if (!diskmap_group_data.files[k].dont_extract_filename) {
|
||||||
diskmap_group_data.files[k].original_filename = diskmap_group_data.files[k].file.replace(diskmap_group_data.base,"").replace(diskmap_data_filename, diskmap_file_data.toString('utf8', 10, gzip_fn_end));
|
diskmap_group_data.files[k].original_filename = diskmap_group_data.files[k].file.replace(diskmap_group_data.base,"").replace(diskmap_data_filename, diskmap_file_data.toString('utf8', 10, gzip_fn_end));
|
||||||
}
|
}
|
||||||
diskmap_group_data.files[k].uncompressed_size = gunzipped.byteLength;
|
diskmap_group_data.files[k].uncompressed_size = gunzipped.byteLength;
|
||||||
gunzipped = null;
|
|
||||||
} else {
|
} else {
|
||||||
diskmap_group_data.files[k].checksum = CryptoJS.MD5(CryptoJS.lib.WordArray.create(diskmap_file_data)).toString(CryptoJS.enc.Hex).toLowerCase();
|
diskmap_group_data.files[k].checksum = CryptoJS.MD5(CryptoJS.lib.WordArray.create(diskmap_file_data)).toString(CryptoJS.enc.Hex).toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -249,8 +248,6 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
|
|
||||||
diskmap_group_data.files[k].invalid = true;
|
diskmap_group_data.files[k].invalid = true;
|
||||||
wtv_download_list.push(diskmap_group_data.files[k]);
|
wtv_download_list.push(diskmap_group_data.files[k]);
|
||||||
// Clean up file data from memory
|
|
||||||
diskmap_file_data = null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// check to see if client says they have this version
|
// check to see if client says they have this version
|
||||||
@@ -265,14 +262,14 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var diskmap_group_name = (diskmap_subgroup == null) ? diskmap_primary_group : diskmap_primary_group + "-" + diskmap_subgroup;
|
const diskmap_group_name = (diskmap_subgroup == null) ? diskmap_primary_group : diskmap_primary_group + "-" + diskmap_subgroup;
|
||||||
diskmap_group_data.client_group_data = client_group_data[diskmap_group_name] || null;
|
diskmap_group_data.client_group_data = client_group_data[diskmap_group_name] || null;
|
||||||
output_data = generateDownloadList(diskmap_group_name, wtv_download_list, diskmap_group_data);
|
output_data = generateDownloadList(diskmap_group_name, wtv_download_list, diskmap_group_data);
|
||||||
return output_data;
|
return output_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diskmap && request_headers.query.group) {
|
if (diskmap && request_headers.query.group) {
|
||||||
var diskmap_json_file = null;
|
let diskmap_json_file = null;
|
||||||
Object.keys(service_vaults).forEach(function (g) {
|
Object.keys(service_vaults).forEach(function (g) {
|
||||||
if (diskmap_json_file != null) return;
|
if (diskmap_json_file != null) return;
|
||||||
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json";
|
||||||
@@ -282,8 +279,8 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
if (diskmap_json_file != null) {
|
if (diskmap_json_file != null) {
|
||||||
try {
|
try {
|
||||||
// read diskmap
|
// read diskmap
|
||||||
var json_stats = fs.lstatSync(diskmap_json_file);
|
const json_stats = fs.lstatSync(diskmap_json_file);
|
||||||
var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
let diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString());
|
||||||
if (!diskmap_data[request_headers.query.group]) {
|
if (!diskmap_data[request_headers.query.group]) {
|
||||||
throw ("Invalid diskmap data (group does not match)");
|
throw ("Invalid diskmap data (group does not match)");
|
||||||
}
|
}
|
||||||
@@ -303,25 +300,25 @@ if (request_headers['wtv-request-type'] == 'download') {
|
|||||||
|
|
||||||
headers = "200 OK\nContent-Type: wtv/download-list";
|
headers = "200 OK\nContent-Type: wtv/download-list";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var errpage = wtvshared.doErrorPage(400);
|
const errpage = wtvshared.doErrorPage(400);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
console.error(" # " + service_name+":/sync error", e);
|
console.error(" # " + service_name+":/sync error", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(404, "The requested DiskMap does not exist.");
|
const errpage = wtvshared.doErrorPage(404, "The requested DiskMap does not exist.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
if (minisrv_config.config.debug_flags.debug) console.error(" # " + service_name +":/sync error", "could not find diskmap");
|
if (minisrv_config.config.debug_flags.debug) console.error(" # " + service_name +":/sync error", "could not find diskmap");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(400);
|
const errpage = wtvshared.doErrorPage(400);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
if (minisrv_config.config.debug_flags.debug) console.error(" # " + service_name + ":/sync error", "missing query arguments");
|
if (minisrv_config.config.debug_flags.debug) console.error(" # " + service_name + ":/sync error", "missing query arguments");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var queryString = Object.keys(request_headers.query)
|
const queryString = Object.keys(request_headers.query)
|
||||||
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(request_headers.query[key]))
|
.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(request_headers.query[key]))
|
||||||
.join('&');
|
.join('&');
|
||||||
headers = "302 Found\nLocation: wtv-disk:/content/DownloadScreen.tmpl" + (queryString ? ("?" + queryString) : "");
|
headers = "302 Found\nLocation: wtv-disk:/content/DownloadScreen.tmpl" + (queryString ? ("?" + queryString) : "");
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
if (request_headers.post_data) {
|
if (request_headers.post_data) {
|
||||||
if (request_headers.query.partialPath || request_headers.query.path) {
|
if (request_headers.query.partialPath || request_headers.query.path) {
|
||||||
if (socket.ssid) {
|
if (socket.ssid) {
|
||||||
if (session_data) {
|
if (session_data) {
|
||||||
if (session_data.isRegistered()) {
|
if (session_data.isRegistered()) {
|
||||||
var result = session_data.storeUserStoreFile(request_headers.query.path || request_headers.query.partialPath, new Buffer.from(request_headers.post_data.toString(CryptoJS.enc.Hex), 'hex'), request_headers.query['last-modified-seconds'] || null, (request_headers.query.no_overwrite) ? false : true);
|
const result = session_data.storeUserStoreFile(request_headers.query.path || request_headers.query.partialPath, new Buffer.from(request_headers.post_data.toString(CryptoJS.enc.Hex), 'hex'), request_headers.query['last-modified-seconds'] || null, (request_headers.query.no_overwrite) ? false : true);
|
||||||
if (result) {
|
if (result) {
|
||||||
headers = "200 OK\n";
|
headers = "200 OK\n";
|
||||||
headers += "Content-Type: text/plain";
|
headers += "Content-Type: text/plain";
|
||||||
@@ -17,7 +17,7 @@ if (request_headers.post_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!headers) {
|
if (!headers) {
|
||||||
var errpage = wtvshared.doErrorPage(400)
|
const errpage = wtvshared.doErrorPage(400)
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
var request_is_async = true;
|
|
||||||
|
|
||||||
var options = {
|
request_is_async = true;
|
||||||
|
|
||||||
|
const options = {
|
||||||
host: "flashrom.webtv.onl",
|
host: "flashrom.webtv.onl",
|
||||||
port: 443,
|
port: 443,
|
||||||
path: "/big-willie.html"
|
path: "/big-willie.html"
|
||||||
};
|
};
|
||||||
|
|
||||||
var data = "";
|
let data = "";
|
||||||
console.log(" * Getting Big Willie Page");
|
console.log(" * Getting Big Willie Page");
|
||||||
|
|
||||||
var req = https.request(options, function(res) {
|
const req = https.request(options, function(res) {
|
||||||
res.setEncoding("utf8");
|
res.setEncoding("utf8");
|
||||||
res.on("data", function (chunk) {
|
res.on("data", function (chunk) {
|
||||||
data += chunk;
|
data += chunk;
|
||||||
@@ -24,12 +25,10 @@ var req = https.request(options, function(res) {
|
|||||||
|
|
||||||
res.on('error', function (e) {
|
res.on('error', function (e) {
|
||||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Upstream Big Willies HTTP Error:", e);
|
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Upstream Big Willies HTTP Error:", e);
|
||||||
var errpage = wtvshared.doErrorPage(400, "A required service is not responding. Please try again in a few moments.");
|
const errpage = wtvshared.doErrorPage(400, "A required service is not responding. Please try again in a few moments.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
req.end();
|
req.end();
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
request_is_async = true;
|
||||||
|
|
||||||
var request_is_async = true;
|
let bf0app_update = false;
|
||||||
|
const request_path = request_headers.request_url.replace(service_name + ":/", "");
|
||||||
var bf0app_update = false;
|
const romtype = session_data.get("wtv-client-rom-type");
|
||||||
var request_path = request_headers.request_url.replace(service_name + ":/", "");
|
const bootver = session_data.get("wtv-client-bootrom-version")
|
||||||
var romtype = session_data.get("wtv-client-rom-type");
|
|
||||||
var bootver = session_data.get("wtv-client-bootrom-version")
|
|
||||||
|
|
||||||
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
|
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
|
||||||
// assume old classic in flash mode, override user setting and send tellyscript
|
// assume old classic in flash mode, override user setting and send tellyscript
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
@@ -7,11 +7,11 @@ request_is_async = true;
|
|||||||
// https://flashrom.webtv.onl/content/artemis-webtv-000/
|
// https://flashrom.webtv.onl/content/artemis-webtv-000/
|
||||||
// and put everything from 'content/' onwards, including the part000.rom filename
|
// and put everything from 'content/' onwards, including the part000.rom filename
|
||||||
// example is below
|
// example is below
|
||||||
var default_build_to_send = minisrv_config.services[service_name].bf0app_default_rom || "content/artemis-webtv-000/build7181/daily-nondebug/bf0app-part000.rom";
|
const default_build_to_send = minisrv_config.services[service_name].bf0app_default_rom || "content/artemis-webtv-000/build7181/daily-nondebug/bf0app-part000.rom";
|
||||||
|
|
||||||
|
|
||||||
var request_path = "";
|
let request_path = "";
|
||||||
var bf0app_update = true;
|
let bf0app_update = true;
|
||||||
if (request_headers.query.path) request_path = request_headers.query.path;
|
if (request_headers.query.path) request_path = request_headers.query.path;
|
||||||
else request_path = default_build_to_send;
|
else request_path = default_build_to_send;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
var bf0app_update = false;
|
let bf0app_update = false;
|
||||||
var request_path = request_headers.query.path;
|
const request_path = request_headers.query.path;
|
||||||
var romtype = session_data.get("wtv-client-rom-type");
|
const romtype = session_data.get("wtv-client-rom-type");
|
||||||
var bootver = session_data.get("wtv-client-bootrom-version")
|
const bootver = session_data.get("wtv-client-bootrom-version");
|
||||||
|
|
||||||
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
|
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
|
||||||
// assume old classic in flash mode, override user setting and send tellyscript
|
// assume old classic in flash mode, override user setting and send tellyscript
|
||||||
@@ -29,7 +29,7 @@ if (request_headers.query.raw || bf0app_update) {
|
|||||||
headers += "Content-type: text/html"
|
headers += "Content-type: text/html"
|
||||||
data = '';
|
data = '';
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(404)
|
const errpage = wtvshared.doErrorPage(404)
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
if (!request_headers.query.path) {
|
if (!request_headers.query.path) {
|
||||||
var errpage = wtvshared.doErrorPage(400);
|
const errpage = wtvshared.doErrorPage(400);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
} else {
|
} else {
|
||||||
@@ -16,8 +16,8 @@ Location: ${service_name}:/lc2-download-complete?`
|
|||||||
data = '';
|
data = '';
|
||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
} else {
|
} else {
|
||||||
var wtvflashrom = new WTVFlashrom(minisrv_config, service_vaults, service_name, minisrv_config.services[service_name].use_zefie_server, false, (minisrv_config.services[service_name].debug ? false : true));
|
const wtvflashrom = new WTVFlashrom(minisrv_config, service_vaults, service_name, minisrv_config.services[service_name].use_zefie_server, false, (minisrv_config.services[service_name].debug ? false : true));
|
||||||
var request_path = request_headers.query.path;
|
const request_path = request_headers.query.path;
|
||||||
|
|
||||||
// read flashrom header info into array using WTVFlashrom class
|
// read flashrom header info into array using WTVFlashrom class
|
||||||
wtvflashrom.getFlashromMeta(request_path, function (data, headers) {
|
wtvflashrom.getFlashromMeta(request_path, function (data, headers) {
|
||||||
@@ -35,7 +35,7 @@ async function processLC2DownloadPage(flashrom_info, headers, numparts = null) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
||||||
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.slice(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
||||||
if (parseInt(flashrom_info.part_number) >= 0 && flashrom_info.rompath && flashrom_info.next_rompath) {
|
if (parseInt(flashrom_info.part_number) >= 0 && flashrom_info.rompath && flashrom_info.next_rompath) {
|
||||||
if (!flashrom_info.message && flashrom_info.is_bootrom) {
|
if (!flashrom_info.message && flashrom_info.is_bootrom) {
|
||||||
flashrom_info.message = "BootRom Part " + (flashrom_info.part_number + 1) + " of " + flashrom_info.part_count;
|
flashrom_info.message = "BootRom Part " + (flashrom_info.part_number + 1) + " of " + flashrom_info.part_count;
|
||||||
@@ -190,7 +190,7 @@ ${flashrom_info.message}
|
|||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(400)
|
const errpage = wtvshared.doErrorPage(400);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?";
|
headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?";
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
if (request_headers.query.path) {
|
if (request_headers.query.path) {
|
||||||
var url = service_name + ":/get-lc2-page?path=" + request_headers.query.path;
|
let url = service_name + ":/get-lc2-page?path=" + request_headers.query.path;
|
||||||
var romtype = session_data.get("wtv-client-rom-type");
|
const romtype = session_data.get("wtv-client-rom-type");
|
||||||
if (romtype == "bf0app") {
|
if (romtype == "bf0app") {
|
||||||
url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + encodeURIComponent(service_name + ":/" + request_headers.query.path);
|
url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + encodeURIComponent(service_name + ":/" + request_headers.query.path);
|
||||||
if (request_headers.query.numparts) url += encodeURIComponent("?numparts=" + request_headers.query.numparts);
|
if (request_headers.query.numparts) url += encodeURIComponent("?numparts=" + request_headers.query.numparts);
|
||||||
@@ -16,7 +16,7 @@ var romtype = session_data.get("wtv-client-rom-type");
|
|||||||
headers += "Content-type: text/html";
|
headers += "Content-type: text/html";
|
||||||
data = '';
|
data = '';
|
||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(400)
|
const errpage = wtvshared.doErrorPage(400)
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-type: text/html
|
Content-type: text/html
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
var error = '';
|
let error = '';
|
||||||
if (request_headers.query.error) {
|
if (request_headers.query.error) {
|
||||||
switch (request_headers.query.error) {
|
switch (request_headers.query.error) {
|
||||||
case "1":
|
case "1":
|
||||||
@@ -34,9 +34,8 @@ if (request_headers.query.error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var try_again_url = service_name + ":/willie";
|
const try_again_url = service_name + ":/willie";
|
||||||
var try_again_url_path = ''
|
const try_again_url_start_time = parseInt(new Date().toUTCString()) / 1000;
|
||||||
var try_again_url_start_time = parseInt(new Date().toUTCString()) / 1000;
|
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-type: text/html`
|
Content-type: text/html`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
@@ -7,18 +7,17 @@ request_is_async = true;
|
|||||||
// https://archive.midnightchannel.net/zefie/files/wtv-flashrom/content/artemis-webtv-000/
|
// https://archive.midnightchannel.net/zefie/files/wtv-flashrom/content/artemis-webtv-000/
|
||||||
// and put everything from 'content/' onwards, including the part000.rom filename
|
// and put everything from 'content/' onwards, including the part000.rom filename
|
||||||
// example is below
|
// example is below
|
||||||
var default_build_to_send = minisrv_config.services[service_name].bf0app_default_rom || "content/artemis-webtv-000/build7181/daily-nondebug/bf0app-part000.rom";
|
const default_build_to_send = minisrv_config.services[service_name].bf0app_default_rom || "content/artemis-webtv-000/build7181/daily-nondebug/bf0app-part000.rom";
|
||||||
|
|
||||||
|
|
||||||
var request_path = "";
|
let request_path = "";
|
||||||
var bf0app_update = true;
|
const bf0app_update = true;
|
||||||
if (request_headers.query.path) request_path = request_headers.query.path;
|
if (request_headers.query.path) request_path = request_headers.query.path;
|
||||||
else request_path = default_build_to_send;
|
else request_path = default_build_to_send;
|
||||||
|
|
||||||
if (session_data.get("wtv-client-rom-type") == "bf0app" && session_data.get("wtv-client-bootrom-version") == "105") {
|
if (session_data.get("wtv-client-rom-type") == "bf0app" && session_data.get("wtv-client-bootrom-version") == "105") {
|
||||||
// assume old classic in flash mode, override user setting and send tellyscript
|
// assume old classic in flash mode, override user setting and send tellyscript
|
||||||
// because it is required to proceed in flash mode
|
// because it is required to proceed in flash mode
|
||||||
bf0app_update = true;
|
|
||||||
session_data.set("bf0app_update", bf0app_update);
|
session_data.set("bf0app_update", bf0app_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
// willie is just a graphical frontend to a list of ROMs
|
// willie is just a graphical frontend to a list of ROMs
|
||||||
// the rest of the scripts should work if you manually link to a ROM, and actually have it.
|
// the rest of the scripts should work if you manually link to a ROM, and actually have it.
|
||||||
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
var proxy_query = '';
|
let proxy_query = '';
|
||||||
if (request_headers.query.flash) delete request_headers.query.flash;
|
if (request_headers.query.flash) delete request_headers.query.flash;
|
||||||
if (request_headers.query.vflash) delete request_headers.query.vflash;
|
if (request_headers.query.vflash) delete request_headers.query.vflash;
|
||||||
if (request_headers.query.pflash) delete request_headers.query.pflash;
|
if (request_headers.query.pflash) delete request_headers.query.pflash;
|
||||||
@@ -18,7 +18,7 @@ if (!minisrv_config.services[service_name].use_zefie_server) {
|
|||||||
proxy_query += "&minisrv_local_mode=true";
|
proxy_query += "&minisrv_local_mode=true";
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
host: "roms.minisrv.dev",
|
host: "roms.minisrv.dev",
|
||||||
path: "/?minisrv=true&service_name="+encodeURIComponent(service_name)+"&pflash=" + session_data.get("wtv-client-rom-type") + proxy_query,
|
path: "/?minisrv=true&service_name="+encodeURIComponent(service_name)+"&pflash=" + session_data.get("wtv-client-rom-type") + proxy_query,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
@@ -35,7 +35,7 @@ const req = https.request(options, function (res) {
|
|||||||
|
|
||||||
res.on('error', function (e) {
|
res.on('error', function (e) {
|
||||||
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Upstream Ultra Willies HTTP Error:", e);
|
if (!minisrv_config.config.debug_flags.quiet) console.log(" * Upstream Ultra Willies HTTP Error:", e);
|
||||||
var errpage = wtvshared.doErrorPage(400, "A required service is not responding. Please try again in a few moments.");
|
const errpage = wtvshared.doErrorPage(400, "A required service is not responding. Please try again in a few moments.");
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var minisrv_service_file = true;
|
const minisrv_service_file = true;
|
||||||
|
|
||||||
data = wtvguide.generatePage(request_headers.query.topic || "Index", request_headers.query.subtopic || "Main", request_headers.query.page || null)
|
data = wtvguide.generatePage(request_headers.query.topic || "Index", request_headers.query.subtopic || "Main", request_headers.query.page || null)
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ if (data) {
|
|||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
Content-Type: text/html`
|
Content-Type: text/html`
|
||||||
} else {
|
} else {
|
||||||
err = wtvshared.doErrorPage(500);
|
const err = wtvshared.doErrorPage(500);
|
||||||
console.log(" * wtv-guide error: no implementation for selected for topic/subtopic, or an error occured during generation")
|
console.log(" * wtv-guide error: no implementation for selected for topic/subtopic, or an error occured during generation")
|
||||||
headers = err[0];
|
headers = err[0];
|
||||||
data = err[1];
|
data = err[1];
|
||||||
|
|||||||
@@ -279,7 +279,10 @@
|
|||||||
"debug": false,
|
"debug": false,
|
||||||
"use_zefie_server": true, // access zefie's repository of flashroms, local roms will still be used if they exist. Best left unchanged.
|
"use_zefie_server": true, // access zefie's repository of flashroms, local roms will still be used if they exist. Best left unchanged.
|
||||||
"bf0app_default_rom": "content/artemis-webtv-000/build7377/internal-nondebug/bf0app-part000.rom", // Can change the default build for bf0app
|
"bf0app_default_rom": "content/artemis-webtv-000/build7377/internal-nondebug/bf0app-part000.rom", // Can change the default build for bf0app
|
||||||
"catchall_file_name": "content-serve.js" // catchall for ROM part files. Best left untouched
|
"catchall_file_name": "content-serve.js", // catchall for ROM part files. Best left untouched
|
||||||
|
"modules": [
|
||||||
|
"WTVFlashrom"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"wtv-setup": {
|
"wtv-setup": {
|
||||||
// wtv-setup
|
// wtv-setup
|
||||||
|
|||||||
@@ -152,6 +152,11 @@ function checkScopeErrors(file) {
|
|||||||
"session_data": "readonly",
|
"session_data": "readonly",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (serviceName === "wtv-guide") {
|
||||||
|
eslintConfig.globals["wtvguide"] = "readonly";
|
||||||
|
}
|
||||||
|
|
||||||
if (service.modules) {
|
if (service.modules) {
|
||||||
for (const moduleName of service.modules) {
|
for (const moduleName of service.modules) {
|
||||||
eslintConfig.globals[moduleName] = "readonly";
|
eslintConfig.globals[moduleName] = "readonly";
|
||||||
|
|||||||
Reference in New Issue
Block a user