fix/optimize wtv-flashrom, wtv-disk, wtv-guide

This commit is contained in:
zefie
2025-08-12 19:47:25 -04:00
parent 8307620004
commit f74cf704de
17 changed files with 119 additions and 118 deletions

View File

@@ -1,16 +1,17 @@
var minisrv_service_file = true;
var request_is_async = true;
const minisrv_service_file = true;
var options = {
request_is_async = true;
const options = {
host: "flashrom.webtv.onl",
port: 443,
path: "/big-willie.html"
};
var data = "";
let data = "";
console.log(" * Getting Big Willie Page");
var req = https.request(options, function(res) {
const req = https.request(options, function(res) {
res.setEncoding("utf8");
res.on("data", function (chunk) {
data += chunk;
@@ -24,12 +25,10 @@ var req = https.request(options, function(res) {
res.on('error', function (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];
data = errpage[1];
sendToClient(socket, headers, data);
});
});
req.end();

View File

@@ -1,11 +1,10 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
var request_is_async = true;
var bf0app_update = false;
var request_path = request_headers.request_url.replace(service_name + ":/", "");
var romtype = session_data.get("wtv-client-rom-type");
var bootver = session_data.get("wtv-client-bootrom-version")
let bf0app_update = false;
const request_path = request_headers.request_url.replace(service_name + ":/", "");
const romtype = session_data.get("wtv-client-rom-type");
const bootver = session_data.get("wtv-client-bootrom-version")
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
// assume old classic in flash mode, override user setting and send tellyscript

View File

@@ -1,4 +1,4 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
@@ -7,11 +7,11 @@ request_is_async = true;
// https://flashrom.webtv.onl/content/artemis-webtv-000/
// and put everything from 'content/' onwards, including the part000.rom filename
// 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 = "";
var bf0app_update = true;
let request_path = "";
let bf0app_update = true;
if (request_headers.query.path) request_path = request_headers.query.path;
else request_path = default_build_to_send;

View File

@@ -1,11 +1,11 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
var bf0app_update = false;
var request_path = request_headers.query.path;
var romtype = session_data.get("wtv-client-rom-type");
var bootver = session_data.get("wtv-client-bootrom-version")
let bf0app_update = false;
const request_path = request_headers.query.path;
const romtype = session_data.get("wtv-client-rom-type");
const bootver = session_data.get("wtv-client-bootrom-version");
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
// 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"
data = '';
} else {
var errpage = wtvshared.doErrorPage(404)
const errpage = wtvshared.doErrorPage(404)
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,9 +1,9 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
if (!request_headers.query.path) {
var errpage = wtvshared.doErrorPage(400);
const errpage = wtvshared.doErrorPage(400);
headers = errpage[0];
data = errpage[1];
} else {
@@ -16,8 +16,8 @@ Location: ${service_name}:/lc2-download-complete?`
data = '';
sendToClient(socket, headers, data);
} 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));
var request_path = request_headers.query.path;
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));
const request_path = request_headers.query.path;
// read flashrom header info into array using WTVFlashrom class
wtvflashrom.getFlashromMeta(request_path, function (data, headers) {
@@ -35,7 +35,7 @@ async function processLC2DownloadPage(flashrom_info, headers, numparts = null) {
return false;
}
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 (!flashrom_info.message && flashrom_info.is_bootrom) {
flashrom_info.message = "BootRom Part " + (flashrom_info.part_number + 1) + " of " + flashrom_info.part_count;
@@ -190,7 +190,7 @@ ${flashrom_info.message}
</body>
</html>`;
} else {
var errpage = wtvshared.doErrorPage(400)
const errpage = wtvshared.doErrorPage(400);
headers = errpage[0];
headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?";
data = errpage[1];

View File

@@ -1,8 +1,8 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
if (request_headers.query.path) {
var url = service_name + ":/get-lc2-page?path=" + request_headers.query.path;
var romtype = session_data.get("wtv-client-rom-type");
let url = service_name + ":/get-lc2-page?path=" + request_headers.query.path;
const romtype = session_data.get("wtv-client-rom-type");
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);
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";
data = '';
} else {
var errpage = wtvshared.doErrorPage(400)
const errpage = wtvshared.doErrorPage(400)
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,4 +1,4 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
headers = `200 OK
Content-type: text/html

View File

@@ -1,6 +1,6 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var error = '';
let error = '';
if (request_headers.query.error) {
switch (request_headers.query.error) {
case "1":
@@ -34,9 +34,8 @@ if (request_headers.query.error) {
}
var try_again_url = service_name + ":/willie";
var try_again_url_path = ''
var try_again_url_start_time = parseInt(new Date().toUTCString()) / 1000;
const try_again_url = service_name + ":/willie";
const try_again_url_start_time = parseInt(new Date().toUTCString()) / 1000;
headers = `200 OK
Content-type: text/html`

View File

@@ -1,4 +1,4 @@
var minisrv_service_file = true;
const minisrv_service_file = 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/
// and put everything from 'content/' onwards, including the part000.rom filename
// 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 = "";
var bf0app_update = true;
let request_path = "";
const bf0app_update = true;
if (request_headers.query.path) request_path = request_headers.query.path;
else request_path = default_build_to_send;
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
// because it is required to proceed in flash mode
bf0app_update = true;
session_data.set("bf0app_update", bf0app_update);
}

View File

@@ -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
// the rest of the scripts should work if you manually link to a ROM, and actually have it.
request_is_async = true;
var proxy_query = '';
let proxy_query = '';
if (request_headers.query.flash) delete request_headers.query.flash;
if (request_headers.query.vflash) delete request_headers.query.vflash;
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";
}
var options = {
const options = {
host: "roms.minisrv.dev",
path: "/?minisrv=true&service_name="+encodeURIComponent(service_name)+"&pflash=" + session_data.get("wtv-client-rom-type") + proxy_query,
timeout: 5000,
@@ -35,7 +35,7 @@ const req = https.request(options, function (res) {
res.on('error', function (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];
data = errpage[1];
sendToClient(socket, headers, data);