fix file loading issues, v0.6.1

This commit is contained in:
zefie
2021-07-15 02:09:37 -04:00
parent a0c8299a31
commit d64e9a0e94
8 changed files with 51 additions and 28 deletions

View File

@@ -6,6 +6,10 @@
# ServiceLogPost Posted Logs
ServiceLogPost/*_*
# Large files not pertaining to the service code
ServiceVault/wtv-flashrom/content/*
ServiceVault/wtv-music/content/*
# User-specific files
*.rsuser
*.suo

View File

@@ -6,8 +6,7 @@ if (socket_session_data[socket.id].ssid != null && !sec_session[socket_session_d
var contype = "text/tellyscript";
// skip telly for now
var notelly = true;
var skip_tellyscript = false;
// if relogin, skip tellyscript
if (query['relogin']) {
@@ -31,8 +30,10 @@ wtv-client-time-dst-rule: GMT
wtv-client-date: `+strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString()))+` GMT`;
// if relogin, skip tellyscript
if (query['relogin'] == false || notelly == false) {
var romtype = null;
if (!query['relogin'] && skip_tellyscript == false) {
var romtype = getSessionData(socket_session_data[socket.id].ssid, 'wtv-client-rom-type');
}
switch (romtype) {
case "US-LC2-disk-0MB-8MB":
@@ -43,4 +44,3 @@ if (query['relogin'] == false || notelly == false) {
data = '';
break;
}
}

View File

@@ -89,6 +89,7 @@ wtv-log-url: wtv-log:/log
wtv-demo-mode: 0
wtv-wink-deferrer-retries: 3
wtv-offline-mail-enable: false
wtv-name-server: 8.8.8.8
wtv-visit: wtv-home:/splash?
Content-Type: text/html`;
}

View File

@@ -1,7 +1,6 @@
headers =`200 OK
Connection: Keep-Alive
wtv-expire-all: wtv-home:/splash
wtv-expire-all: htv-
Content-type: text/html`
if (getSessionData(socket_session_data[socket.id].ssid, 'box-does-psuedo-encryption')) {
@@ -30,11 +29,17 @@ if (socket_session_data[socket.id].secure) {
data += '<span size="-1">Encryption Key (Server): ' + sec_session[socket.id].session_key2.toString(CryptoJS.enc.Hex)+'<br>';
data += 'Encryption Key (Client): ' + sec_session[socket.id].session_key1.toString(CryptoJS.enc.Hex)+'</span><br><br>';
}
data += `<a href="client:relog">client:relog (direct)</a><br>
data += `<h4>Working stuff</h4>
<a href="client:relog">client:relog (direct)</a><br>
<a href="wtv-tricks:/blastcache?">Clear Cache</a><br>
<h4>zefie's server only</h4>
<a href="wtv-music:/content/index.html">Music Collection</a><br>
<h4>Test Stuff (probably broken)</h4>
<a href="wtv-update:/update?" selected>HackTV Updater Test</a><br>
<a href="wtv-flashrom:/willie">Ultra Willies</a><br>
<a href="client:showalert?message=If%20you%20choose%20to%20disconnect%20and%20return%20to%20HackTV%20home%2C%20you%20may%20not%20be%20able%20to%20reconnect%20to%20the%20update%20server%20until%20you%20power%20cycle%20your%20box.%3Cbr%3E%3Cbr%3EAre%20you%20sure%20you%20would%20like%20to%20go%20offline%3F&buttonlabel1=No&buttonaction1=client:donothing&buttonlabel2=Yes&buttonaction2=wtv-tricks:/go-offline?title=HackTV%20Home">Disconnect and go to HackTV Home</a><br>
<a href="client:showalert?message=If%20you%20choose%20to%20disconnect%20and%20return%20to%20HackTV%20home%2C%20you%20may%20not%20be%20able%20to%20reconnect%20to%20the%20update%20server%20until%20you%20power%20cycle%20your%20box.%3Cbr%3E%3Cbr%3EAre%20you%20sure%20you%20would%20like%20to%20go%20offline%3F&buttonlabel1=No&buttonaction1=client:donothing&buttonlabel2=Yes&buttonaction2=wtv-tricks%3A%2Fgo-offline%3Ftitle%3DHackTV%2520Home">Disconnect and go to HackTV Home</a><br>
<!-- <a href="buttonaction2=wtv-home:/unlock">Unlock Full Client (Options, Goto, etc)</a><br> -->
</body>

View File

@@ -1,6 +1,9 @@
var content_dir = service_dir + '/content/';
var diskmap_dir = content_dir + '/diskmaps/';
if (initial_headers['post_data']) {
console.log(initial_headers['post_data'].toString('CryptoJS.enc.Latin1'))
}
if (query['diskmap']) {
if (fs.lstatSync(diskmap_dir + query['diskmap'] + ".txt")) {

View File

@@ -10,7 +10,7 @@ const mime = require('mime-types');
const crc16 = require('node-crc16');
var WTVSec = require('./wtvsec.js');
var zdebug = false;
var zdebug = true;
var ports = [];
@@ -140,7 +140,7 @@ async function processPath(socket, path, request_headers = new Array(), query =
// file exists, read it and return it
console.log(" * Found " + path + " to handle request (Direct File Mode) [Socket " + socket.id +"]");
var contype = getConType(path);
data = fs.readFileSync(path).buffer;
data = new Uint8Array(fs.readFileSync(path)).buffer;
headers = "200 OK\n"
headers += "Content-Type: " + contype;
} else if (fs.existsSync(path + ".txt")) {
@@ -204,13 +204,6 @@ async function processPath(socket, path, request_headers = new Array(), query =
data = errpage[1] + "<br><br>The interpreter said:<br><pre>" + e.toString() + "</pre>";
console.log(e);
}
if (headers.toLowerCase().indexOf("content-length") === -1) {
if (typeof data.length !== 'undefined') {
headers += "\nContent-Length: " + data.length;
} else if (typeof data.byteLength !== 'undefined') {
headers += "\nContent-Length: " + data.byteLength;
}
}
return new Array(headers, data);
}
@@ -284,7 +277,8 @@ async function processURL(socket, request_headers) {
// error reading headers (no request_url provided)
var errpage = doErrorPage(400);
headers = errpage[0];
data = errpage[1];
data = errpage[1]
socket_session_data[socket.id].close_me = true;
}
// headers to object
@@ -337,14 +331,26 @@ async function processURL(socket, request_headers) {
headers_obj = moveObjectElement('wtv-encrypted', 'Connection', headers_obj);
if (clen > 0) {
console.log(" * Encrypting response to client ...")
var data_type = typeof (data);
if (typeof (data) === 'string') {
data = CryptoJS.enc.Utf8.parse(data);
}
if (data.constructor === ArrayBuffer) {
data = CryptoJS.lib.WordArray.create(data);
}
var enc_data = sec_session[socket.id].Encrypt(1,data);
data = enc_data;
}
}
if (!headers_obj["Content-length"] && !headers_obj["Content-length"]) {
if (typeof data.length !== 'undefined') {
headers_obj['Content-Length'] = data.length;
} else if (typeof data.byteLength !== 'undefined') {
headers_obj['Content-Length'] = data.byteLength;
}
}
headers = "";
console.log(headers_obj);
Object.keys(headers_obj).forEach(function (k) {
@@ -624,13 +630,12 @@ async function handleSocket(socket) {
socket.setTimeout(0);
var phead = await processHeaders(this, socket_buffer[socket.id].toString(CryptoJS.enc.Hex));
processURL(this, phead);
if (socket_session_data[socket.id].close_me) socket.end();
socket_buffer[socket.id] = null;
});
socket.on('error', (err) => {
console.log(" * Client disconnected unexpectedly");
cleanupSocket(socket);
socket.end();
});
socket.on('end', function () {

View File

@@ -1,6 +1,6 @@
{
"name": "hacktv_updsrv",
"version": "0.6.0",
"version": "0.6.1",
"description": "hacktv_updsrv",
"main": "app.js",
"author": {

View File

@@ -37,6 +37,11 @@
"wtv-flashrom": {
"port": 1618,
"flags": "0x00000040"
},
"wtv-music": {
"port": 1656,
"flags": "0x04",
"connections": 3
}
}
}