fix file loading issues, v0.6.1
This commit is contained in:
4
hacktv_updsrv/.gitignore
vendored
4
hacktv_updsrv/.gitignore
vendored
@@ -6,6 +6,10 @@
|
|||||||
# ServiceLogPost Posted Logs
|
# ServiceLogPost Posted Logs
|
||||||
ServiceLogPost/*_*
|
ServiceLogPost/*_*
|
||||||
|
|
||||||
|
# Large files not pertaining to the service code
|
||||||
|
ServiceVault/wtv-flashrom/content/*
|
||||||
|
ServiceVault/wtv-music/content/*
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ if (socket_session_data[socket.id].ssid != null && !sec_session[socket_session_d
|
|||||||
|
|
||||||
var contype = "text/tellyscript";
|
var contype = "text/tellyscript";
|
||||||
|
|
||||||
// skip telly for now
|
var skip_tellyscript = false;
|
||||||
var notelly = true;
|
|
||||||
|
|
||||||
// if relogin, skip tellyscript
|
// if relogin, skip tellyscript
|
||||||
if (query['relogin']) {
|
if (query['relogin']) {
|
||||||
@@ -31,10 +30,12 @@ wtv-client-time-dst-rule: GMT
|
|||||||
wtv-client-date: `+strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString()))+` GMT`;
|
wtv-client-date: `+strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString()))+` GMT`;
|
||||||
|
|
||||||
// if relogin, skip tellyscript
|
// 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');
|
var romtype = getSessionData(socket_session_data[socket.id].ssid, 'wtv-client-rom-type');
|
||||||
|
}
|
||||||
|
|
||||||
switch (romtype) {
|
switch (romtype) {
|
||||||
case "US-LC2-disk-0MB-8MB":
|
case "US-LC2-disk-0MB-8MB":
|
||||||
data = getFile("LC2/LC2_OISP_5555732_56k.tok", true);
|
data = getFile("LC2/LC2_OISP_5555732_56k.tok", true);
|
||||||
break;
|
break;
|
||||||
@@ -42,5 +43,4 @@ if (query['relogin'] == false || notelly == false) {
|
|||||||
default:
|
default:
|
||||||
data = '';
|
data = '';
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,7 @@ wtv-log-url: wtv-log:/log
|
|||||||
wtv-demo-mode: 0
|
wtv-demo-mode: 0
|
||||||
wtv-wink-deferrer-retries: 3
|
wtv-wink-deferrer-retries: 3
|
||||||
wtv-offline-mail-enable: false
|
wtv-offline-mail-enable: false
|
||||||
|
wtv-name-server: 8.8.8.8
|
||||||
wtv-visit: wtv-home:/splash?
|
wtv-visit: wtv-home:/splash?
|
||||||
Content-Type: text/html`;
|
Content-Type: text/html`;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
headers =`200 OK
|
headers =`200 OK
|
||||||
Connection: Keep-Alive
|
Connection: Keep-Alive
|
||||||
wtv-expire-all: wtv-home:/splash
|
wtv-expire-all: wtv-home:/splash
|
||||||
wtv-expire-all: htv-
|
|
||||||
Content-type: text/html`
|
Content-type: text/html`
|
||||||
|
|
||||||
if (getSessionData(socket_session_data[socket.id].ssid, 'box-does-psuedo-encryption')) {
|
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 += '<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 += '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>
|
<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-update:/update?" selected>HackTV Updater Test</a><br>
|
||||||
<a href="wtv-flashrom:/willie">Ultra Willies</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> -->
|
<!-- <a href="buttonaction2=wtv-home:/unlock">Unlock Full Client (Options, Goto, etc)</a><br> -->
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
var content_dir = service_dir + '/content/';
|
var content_dir = service_dir + '/content/';
|
||||||
var diskmap_dir = content_dir + '/diskmaps/';
|
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 (query['diskmap']) {
|
||||||
if (fs.lstatSync(diskmap_dir + query['diskmap'] + ".txt")) {
|
if (fs.lstatSync(diskmap_dir + query['diskmap'] + ".txt")) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const mime = require('mime-types');
|
|||||||
const crc16 = require('node-crc16');
|
const crc16 = require('node-crc16');
|
||||||
var WTVSec = require('./wtvsec.js');
|
var WTVSec = require('./wtvsec.js');
|
||||||
|
|
||||||
var zdebug = false;
|
var zdebug = true;
|
||||||
|
|
||||||
var ports = [];
|
var ports = [];
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ async function processPath(socket, path, request_headers = new Array(), query =
|
|||||||
// file exists, read it and return it
|
// file exists, read it and return it
|
||||||
console.log(" * Found " + path + " to handle request (Direct File Mode) [Socket " + socket.id +"]");
|
console.log(" * Found " + path + " to handle request (Direct File Mode) [Socket " + socket.id +"]");
|
||||||
var contype = getConType(path);
|
var contype = getConType(path);
|
||||||
data = fs.readFileSync(path).buffer;
|
data = new Uint8Array(fs.readFileSync(path)).buffer;
|
||||||
headers = "200 OK\n"
|
headers = "200 OK\n"
|
||||||
headers += "Content-Type: " + contype;
|
headers += "Content-Type: " + contype;
|
||||||
} else if (fs.existsSync(path + ".txt")) {
|
} 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>";
|
data = errpage[1] + "<br><br>The interpreter said:<br><pre>" + e.toString() + "</pre>";
|
||||||
console.log(e);
|
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);
|
return new Array(headers, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +277,8 @@ async function processURL(socket, request_headers) {
|
|||||||
// error reading headers (no request_url provided)
|
// error reading headers (no request_url provided)
|
||||||
var errpage = doErrorPage(400);
|
var errpage = doErrorPage(400);
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
data = errpage[1];
|
data = errpage[1]
|
||||||
|
socket_session_data[socket.id].close_me = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// headers to object
|
// headers to object
|
||||||
@@ -337,14 +331,26 @@ async function processURL(socket, request_headers) {
|
|||||||
headers_obj = moveObjectElement('wtv-encrypted', 'Connection', headers_obj);
|
headers_obj = moveObjectElement('wtv-encrypted', 'Connection', headers_obj);
|
||||||
if (clen > 0) {
|
if (clen > 0) {
|
||||||
console.log(" * Encrypting response to client ...")
|
console.log(" * Encrypting response to client ...")
|
||||||
|
var data_type = typeof (data);
|
||||||
if (typeof (data) === 'string') {
|
if (typeof (data) === 'string') {
|
||||||
data = CryptoJS.enc.Utf8.parse(data);
|
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);
|
var enc_data = sec_session[socket.id].Encrypt(1,data);
|
||||||
data = enc_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 = "";
|
headers = "";
|
||||||
console.log(headers_obj);
|
console.log(headers_obj);
|
||||||
Object.keys(headers_obj).forEach(function (k) {
|
Object.keys(headers_obj).forEach(function (k) {
|
||||||
@@ -624,13 +630,12 @@ async function handleSocket(socket) {
|
|||||||
socket.setTimeout(0);
|
socket.setTimeout(0);
|
||||||
var phead = await processHeaders(this, socket_buffer[socket.id].toString(CryptoJS.enc.Hex));
|
var phead = await processHeaders(this, socket_buffer[socket.id].toString(CryptoJS.enc.Hex));
|
||||||
processURL(this, phead);
|
processURL(this, phead);
|
||||||
|
if (socket_session_data[socket.id].close_me) socket.end();
|
||||||
socket_buffer[socket.id] = null;
|
socket_buffer[socket.id] = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('error', (err) => {
|
socket.on('error', (err) => {
|
||||||
console.log(" * Client disconnected unexpectedly");
|
socket.end();
|
||||||
cleanupSocket(socket);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('end', function () {
|
socket.on('end', function () {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hacktv_updsrv",
|
"name": "hacktv_updsrv",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"description": "hacktv_updsrv",
|
"description": "hacktv_updsrv",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -37,6 +37,11 @@
|
|||||||
"wtv-flashrom": {
|
"wtv-flashrom": {
|
||||||
"port": 1618,
|
"port": 1618,
|
||||||
"flags": "0x00000040"
|
"flags": "0x00000040"
|
||||||
|
},
|
||||||
|
"wtv-music": {
|
||||||
|
"port": 1656,
|
||||||
|
"flags": "0x04",
|
||||||
|
"connections": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user