- fix: wtv-home:/home: remove `nostatus` to enable loading progress bar for outgoing links
 - fix: wtv-1800:/finish-prereg: swap error message location for better debugging
 - fix: app.js: Properly clean up old sockets
 - fix: wtv-flashrom: fix search for local flashrom files
 - update: wtv-home:/home: add link to access downloaded DealerDemo
This commit is contained in:
zefie
2021-07-21 15:54:02 -04:00
parent e18be0d9d7
commit 344058828e
6 changed files with 40 additions and 23 deletions

View File

@@ -5,7 +5,8 @@ if (socket.ssid != null) {
ssid_sessions[socket.ssid].data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
}
} else {
var errpage = doErrorCode(400);
console.log(" * Something bad happened (we don't know the client ssid???)");
var errpage = doErrorCode(400)
headers = errpage[0];
data = errpage[1];
}
@@ -63,8 +64,7 @@ wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCS
});
}
} else {
console.log(" * Something bad happened (we don't know the client ssid???)");
var errpage = doErrorCode(400)
var errpage = doErrorCode(400);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -26,8 +26,13 @@ function doLocalFlashROM(flashrom_file_path) {
if (request_headers.query.raw) {
if ((/\.brom$/).test(request_path)) headers += "Content-Type: binary/x-wtv-bootrom"; // maybe?
else headers += "Content-Type: binary/x-wtv-flashblock";
var flashrom_file_path = service_dir + '/' + request_path;
if (minisrv_config.services[service_name].use_zefie_server && !fs.existsSync(flashrom_file_path)) {
var flashrom_file_path = null;
Object.keys(service_vaults).forEach(function (g) {
if (flashrom_file_path != null) return;
flashrom_file_path = service_vaults[g].path + "/" + service_name + "/" + request_path;
if (!fs.existsSync(flashrom_file_path)) flashrom_file_path = null;
});
if (minisrv_config.services[service_name].use_zefie_server && !flashrom_file_path) {
// get flashrom files from archive.midnightchannel.net
var options = {
host: "archive.midnightchannel.net",

View File

@@ -26,8 +26,14 @@ if (!request_headers.query.path) {
data = errpage[1];
} else {
var request_path = unescape(request_headers.query.path);
var flashrom_file_path = service_dir + '/' + request_path;
if (minisrv_config.services[service_name].use_zefie_server && !fs.existsSync(flashrom_file_path)) {
var flashrom_file_path = null;
Object.keys(service_vaults).forEach(function (g) {
if (flashrom_file_path != null) return;
flashrom_file_path = service_vaults[g].path + "/" + service_name + "/" + request_path;
if (!fs.existsSync(flashrom_file_path)) flashrom_file_path = null;
});
if (minisrv_config.services[service_name].use_zefie_server && !flashrom_file_path) {
// read first 256 bytes of flashrom file from archive.midnightchannel.net
// to get `flashrom_message` and `numparts` if missing
var options = {

View File

@@ -14,7 +14,7 @@ if (ssid_sessions[socket.ssid].get('box-does-psuedo-encryption')) {
data =`<html>
<head>
<title>Home for minisrv</title>
<DISPLAY NoLogo NoStatus hideoptions noscroll>
<DISPLAY NoLogo hideoptions noscroll>
</head>
<body bgcolor="black" link="gold" vlink="gold" alink="gold" text="gold">
<script>
@@ -31,7 +31,7 @@ Connection Speed: &rate;
<li><a href="wtv-tricks:/blastcache?return_to=wtv-home:/home">Clear Cache</a></li>
<li><a href="wtv-flashrom:/willie">Ultra Willies</a></li>
<li><a href="wtv-music:/demo/index">MIDI Music Demo</a></li>
<li><a href="wtv-update:/DealerDemo">Download old MSNTV DealerDemo</a></li>
<li>Old MSNTV DealerDemo: <a href="wtv-update:/DealerDemo">Download</a> ~ <a href="file://Disk/Demo/index.html">Access (after Download)</a></li>
<li><a href="http://duckduckgo.com/lite/">DuckDuckGo Lite</a></li>
<li><input name=url `;

View File

@@ -596,9 +596,9 @@ async function processRequest(socket, data_hex, returnHeadersBeforeSecure = fals
socket.ssid = headers["wtv-client-serial-number"];
if (!ssid_sessions[socket.ssid]) {
ssid_sessions[socket.ssid] = new ClientSessionData();
ssid_sessions[socket.ssid].sockets = new Array();
ssid_sessions[socket.ssid].sockets.push(socket.id);
}
if (!ssid_sessions[socket.ssid].data_store.sockets) ssid_sessions[socket.ssid].data_store.sockets = new Array();
ssid_sessions[socket.ssid].data_store.sockets.push(socket.id);
}
@@ -751,18 +751,19 @@ async function checkForPostData(socket, headers, data, data_hex) {
async function cleanupSocket(socket) {
try {
if (!zquiet) console.log(" * Destroying old WTVSec instance on disconnected socket", socket.id);
delete socket_sessions[socket.id].buffer;
delete socket_sessions[socket.id].wtvsec;
if (socket_sessions[socket.id]) {
if (!zquiet) console.log(" * Cleaning up disconnected socket", socket.id);
delete socket_sessions[socket.id];
if (socket.ssid) {
if (ssid_sessions[socket.ssid].sockets.findIndex(element => element = socket.id) != -1) {
ssid_sessions[socket.ssid].sockets.splice(ssid_sessions[socket.ssid].sockets.findIndex(element => element = socket.id));
}
var fuckyou = ssid_sessions[socket.ssid].sockets;
if (ssid_sessions[socket.ssid].sockets.length === 0 && ssid_sessions[socket.ssid].get("wtvsec_login")) {
if (socket.ssid) {
var socket_array_index = ssid_sessions[socket.ssid].data_store.sockets.findIndex(element => element = socket.id);
if (socket_array_index != -1) {
ssid_sessions[socket.ssid].data_store.sockets.splice(socket_array_index,1);
}
if (ssid_sessions[socket.ssid].data_store.sockets.length === 0 && ssid_sessions[socket.ssid].data_store.wtvsec_login) {
// if last socket for SSID disconnected, destroy login session
if (!zquiet) console.log(" * Last socket from WebTV SSID", filterSSID(socket.ssid),"disconnected, destroying initial WTVSec instance");
if (!zquiet) console.log(" * Last socket from WebTV SSID", filterSSID(socket.ssid),"disconnected, cleaning up primary WTVSec instance for this SSID");
ssid_sessions[socket.ssid].delete("wtvsec_login");
}
}
@@ -814,6 +815,11 @@ async function handleSocket(socket) {
// Attempt to clean up all of our WTVSec instances
cleanupSocket(socket);
});
socket.on('close', function () {
// Attempt to clean up all of our WTVSec instances
cleanupSocket(socket);
});
}
function integrateConfig(main, user) {

View File

@@ -1,6 +1,6 @@
{
"name": "zefie_wtvp_minisrv",
"version": "0.9.2",
"version": "0.9.3",
"description": "WebTV Service (WTVP) Emulation Server",
"main": "app.js",
"homepage": "https://github.com/zefie/zefie_wtvp_minisrv",