update: WTVClientCapabilities: add unknown bits instead of logging error
update: fix flashrom system update: webone example config update: app.js: more 'binary block' exclusions update: fix tellyscript folder name for case-sensitive filesystems
This commit is contained in:
@@ -162,6 +162,20 @@ AddRedirect=http://web.archive.org/web/1997/%URL%
|
||||
[Edit:^(http://www\.|http://)microsoft.com/IE/]
|
||||
AddRedirect=http://web.archive.org/web/1997/%URL%
|
||||
|
||||
; WebTV
|
||||
[Edit:^http://developer.webtv.net/]
|
||||
AddRedirect=http://web.archive.org/web/20010118212000/%URL%
|
||||
|
||||
[Edit:^http://www.crosswinds.net/~lsyndicate/cara/]
|
||||
AddRedirect=http://web.archive.org/web/20000815230842/%URL%
|
||||
|
||||
[Edit:^http://www.webtvaudio.com/]
|
||||
AddRedirect=https://web.archive.org/web/20010720053557/%URL%
|
||||
|
||||
[Edit:^http://soweird.mine.nu/]
|
||||
AddRedirect=https://web.archive.org/web/20010720053557/%URL%
|
||||
|
||||
|
||||
[Edit:\.cdf$]
|
||||
IgnoreUrl=web.archive.org
|
||||
AddRedirect=http://web.archive.org/web/1998/%URL%
|
||||
@@ -259,6 +273,7 @@ OnHeader=User-Agent: Mozilla/0
|
||||
OnHeader=User-Agent: Mozilla/1
|
||||
OnHeader=User-Agent: Mozilla/2
|
||||
OnHeader=User-Agent: Mozilla/3
|
||||
OnHeader=User-Agent: WebTV
|
||||
IgnoreUrl=webdav
|
||||
AddConvert=convert
|
||||
AddConvertDest=gif
|
||||
@@ -267,13 +282,14 @@ AddResponseHeader=Content-Type: image/gif
|
||||
; uncomment section below to enable JPG recompression
|
||||
[Edit]
|
||||
OnContentType=image/jpeg
|
||||
OnContentType=image/jpg
|
||||
;OnContentType=image/png
|
||||
;OnContentType=image/webp
|
||||
OnCode=200
|
||||
IgnoreUrl=webdav
|
||||
AddConvert=convert
|
||||
AddConvertDest=jpg
|
||||
AddConvertArg1=-quality 50
|
||||
AddConvertArg1=-quality 35 -resize 640x480>
|
||||
AddResponseHeader=Content-Type: image/jpeg
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ request_is_async = true;
|
||||
|
||||
var bf0app_update = false;
|
||||
var request_path = unescape(request_headers.query.path);
|
||||
var romtype = ssid_sessions[socket.ssid].get("wtv-client-rom-type");
|
||||
var bootver = ssid_sessions[socket.ssid].get("wtv-client-bootrom-version")
|
||||
|
||||
if (ssid_sessions[socket.ssid].get("wtv-client-rom-type") == "bf0app" && ssid_sessions[socket.ssid].get("wtv-client-bootrom-version") == "105") {
|
||||
if ((romtype == "bf0app" || !romtype) && (bootver == "105" || !bootver)) {
|
||||
// assume old classic in flash mode, override user setting and send tellyscript
|
||||
// because it is required to proceed in flash mode
|
||||
bf0app_update = true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
const WTVFlashrom = require("./WTVFlashrom.js");
|
||||
var wtvflashrom;
|
||||
var flashrom_info;
|
||||
request_is_async = true;
|
||||
|
||||
if (!request_headers.query.path) {
|
||||
@@ -12,19 +11,18 @@ if (!request_headers.query.path) {
|
||||
var wtvflashrom = new WTVFlashrom(service_vaults, service_name, minisrv_config.services[service_name].use_zefie_server);
|
||||
var request_path = unescape(request_headers.query.path);
|
||||
|
||||
// read 512 bytes of rom
|
||||
flashrom_info = wtvflashrom.getFlashRom(request_path, function (data, headers = null) {
|
||||
// read flashrom header info into array using WTVFlashrom class
|
||||
wtvflashrom.getFlashromMeta(request_path, function (data) {
|
||||
processLC2DownloadPage(request_headers.query.path, data, (request_headers.query.numparts || null));
|
||||
}, 512);
|
||||
});
|
||||
}
|
||||
|
||||
async function processLC2DownloadPage(path, flashrom_info, numparts = null) {
|
||||
var flashrom_numparts = null;
|
||||
if (numparts != null) flashrom_numparts = parseInt(numparts);
|
||||
if (!flashrom_numparts) flashrom_numparts = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
||||
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.is_last_part) {
|
||||
flashrom_info.next_rompath = flashrom_info.next_rompath.replace("get-by-path", "get-lc2-page").replace("&raw=true", "&numparts=" + parseInt(flashrom_numparts));
|
||||
flashrom_info.next_rompath = flashrom_info.next_rompath.replace("get-by-path", "get-lc2-page").replace("&raw=true", "&numparts=" + flashrom_info.part_count);
|
||||
}
|
||||
if (!flashrom_info.part_number || !flashrom_info.is_last_part || !flashrom_info.rompath || !flashrom_info.next_rompath || !flashrom_info.is_bootrom) {
|
||||
|
||||
@@ -99,8 +97,8 @@ blockurl="${flashrom_info.rompath}"
|
||||
lastblock="${flashrom_info.is_last_part}"
|
||||
curblock="` + (flashrom_info.part_number + 1) + `"
|
||||
`
|
||||
if (flashrom_numparts) {
|
||||
data += `totalblocks="${flashrom_numparts}"`;
|
||||
if (flashrom_info.part_count) {
|
||||
data += `totalblocks="${flashrom_info.part_count}"`;
|
||||
}
|
||||
data += `>
|
||||
<font size="-1" color="#D6DFD0">
|
||||
|
||||
@@ -122,6 +122,7 @@ class WTVClientCapabilities {
|
||||
capabilities[flag_name] = flag;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
// process bitfield and set capabilities
|
||||
Object.keys(bitfield).forEach(function (k) {
|
||||
// Convert binary to boolean, 0 to false, 1 to true
|
||||
@@ -131,7 +132,9 @@ class WTVClientCapabilities {
|
||||
try {
|
||||
add(capabilities_table[k][0], bitfield_result);
|
||||
} catch (ex) {
|
||||
console.error(" * Unknown configuration bit", k);
|
||||
add('unknown-capability-' + i, bitfield_result);
|
||||
i++;
|
||||
//console.error(" * Unknown configuration bit", k, "with value", bitfield_result);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class WTVFlashrom {
|
||||
}
|
||||
|
||||
|
||||
getFlashromData(data, path) {
|
||||
getFlashromInfo(data, path) {
|
||||
var flashrom_info = new Array();
|
||||
var flashrom_magic = "96031889";
|
||||
var part_header = new Buffer.alloc(32);
|
||||
@@ -109,15 +109,21 @@ class WTVFlashrom {
|
||||
async sendToClient(data, request_path, callback) {
|
||||
var headers = "200 OK\n";
|
||||
if (this.bf0app_update) headers += "minisrv-use-carriage-return: false\n";
|
||||
var flashrom_info = this.getFlashromData(data, request_path)
|
||||
var flashrom_info = this.getFlashromInfo(data, request_path)
|
||||
if (flashrom_info.is_bootrom) headers += "Content-Type: binary/x-wtv-bootrom"; // maybe?
|
||||
else headers += "Content-Type: binary/x-wtv-flashblock";
|
||||
if (flashrom_info.next_rompath != null) headers += "\nwtv-visit: " + flashrom_info.next_rompath;
|
||||
callback(data, headers);
|
||||
}
|
||||
|
||||
async getFlashromMeta(request_path, callback) {
|
||||
// read 512 bytes of rom, and send result of getFlashromInfo
|
||||
// to callback (in data), without headers
|
||||
this.getFlashRom(request_path, callback, 512);
|
||||
}
|
||||
|
||||
async getFlashRom(request_path, callback, length = 0) {
|
||||
var flashrom_file_path = null;
|
||||
var headers, flashrom_file_path = null;
|
||||
var self = this;
|
||||
Object.keys(self.service_vaults).forEach(function (g) {
|
||||
if (flashrom_file_path != null) return;
|
||||
@@ -151,21 +157,20 @@ class WTVFlashrom {
|
||||
if (res.statusCode == 200) {
|
||||
var data = Buffer.from(data_hex, 'hex');
|
||||
} else if (res.statusCode == 206) {
|
||||
headers = "";
|
||||
var data = self.getFlashromData(Buffer.from(data_hex, 'hex'), request_path);
|
||||
var data = self.getFlashromInfo(Buffer.from(data_hex, 'hex'), request_path);
|
||||
} else if (res.statusCode == 404) {
|
||||
var errpage = doErrorPage(404, "The service could not find the requested ROM on zefie's server.")
|
||||
var headers = errpage[0];
|
||||
headers = errpage[0];
|
||||
var data = errpage[1];
|
||||
} else {
|
||||
var errpage = doErrorPage(400)
|
||||
var headers = errpage[0];
|
||||
headers = errpage[0];
|
||||
var data = errpage[1];
|
||||
}
|
||||
if (res.statusCode == "206") {
|
||||
if (res.statusCode != 206) {
|
||||
self.sendToClient(data, request_path, callback);
|
||||
} else {
|
||||
callback(data);
|
||||
callback(data, headers);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -594,7 +594,7 @@ function headersAreStandard(string, verbose = false) {
|
||||
// in unencrypted headers, and returns true only if every character in the string matches
|
||||
// the regex. Once we know the string is binary, we can better process it with the
|
||||
// raw base64 or hex data in processRequest() below.
|
||||
return /^([A-Za-z0-9\+\/\=\-\.\,\ \"\;\:\?\&\r\n\(\)\%\<\>\_\~]{8,})$/.test(string);
|
||||
return /^([A-Za-z0-9\+\/\=\-\.\,\ \"\;\:\?\&\r\n\(\)\%\<\>\_\~\*]{8,})$/.test(string);
|
||||
}
|
||||
|
||||
async function processRequest(socket, data_hex, skipSecure = false, encryptedRequest = false) {
|
||||
|
||||
Reference in New Issue
Block a user