v0.9.9
- update: config.json: add DoNotEncrypt flags to http and https - update: app.js: add ability to override service flags when using getServiceString - update: app.js: add ability to disable 'wtv-star' while keeping 'wtv-*' - update: app.js: add internal header 'minisrv-use-carriage-return', set to 'false' to disable `\r` in headers - implement bf0app flashrom functionality
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
request_is_async = true;
|
||||
|
||||
|
||||
var bf0app_update = false;
|
||||
var request_path = unescape(request_headers.query.path);
|
||||
headers = "200 OK\n"
|
||||
|
||||
@@ -22,11 +24,44 @@ function doLocalFlashROM(flashrom_file_path) {
|
||||
}
|
||||
}
|
||||
|
||||
var romtype = ssid_sessions[socket.ssid].get("wtv-client-rom-type");
|
||||
if (ssid_sessions[socket.ssid].get("wtv-client-rom-type") == "bf0app" && ssid_sessions[socket.ssid].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;
|
||||
ssid_sessions[socket.ssid].set("bf0app_update", bf0app_update);
|
||||
headers += "minisrv-use-carriage-return: false\n";
|
||||
}
|
||||
|
||||
if (request_headers.query.raw || romtype == "bf0app") {
|
||||
|
||||
function calculatedPath(data, path, numparts = null) {
|
||||
var data_128 = new Buffer.alloc(128);
|
||||
data.copy(data_128, 0, 0, 128);
|
||||
var flashrom_numparts = null;
|
||||
var flashrom_message = new Buffer.from(data_128.toString('hex').substring(36 * 2, 68 * 2), 'hex').toString('ascii').replace(/[^0-9a-z\ \.\-]/gi, "");
|
||||
|
||||
if (numparts != null) flashrom_numparts = parseInt(numparts);
|
||||
if (!flashrom_numparts) flashrom_numparts = flashrom_message.substring(flashrom_message.length - 4).replace(/\D/g, '');
|
||||
|
||||
var ind = new Array();
|
||||
ind[0] = (path.indexOf("part") + 4);
|
||||
ind[1] = (path.indexOf(".", ind[0]) + 1);
|
||||
var flashrom_part_num = path.substr(ind[0], (path.length - ind[1]));
|
||||
var flashrom_lastpart = (flashrom_numparts == (parseInt(flashrom_part_num) + 1)) ? true : false;
|
||||
var flashrom_rompath = 'wtv-flashrom:/get-by-path?path=' + path;
|
||||
if (flashrom_lastpart) flashrom_next_rompath = null;
|
||||
else {
|
||||
var flashrom_next_part_num = (parseInt(flashrom_part_num) + 1);
|
||||
if (flashrom_next_part_num < 10) flashrom_next_part_num = "00" + flashrom_next_part_num; // 1s
|
||||
else if (flashrom_next_part_num >= 10 && flashrom_next_part_num < 100) flashrom_next_part_num = "0" + flashrom_next_part_num; // 10s
|
||||
var flashrom_next_rompath = flashrom_rompath.replace("part" + flashrom_part_num, "part" + flashrom_next_part_num) + "&numparts=" + parseInt(flashrom_numparts);
|
||||
}
|
||||
return flashrom_next_rompath;
|
||||
}
|
||||
|
||||
if (request_headers.query.raw || bf0app_update) {
|
||||
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 = null;
|
||||
Object.keys(service_vaults).forEach(function (g) {
|
||||
if (flashrom_file_path != null) return;
|
||||
@@ -62,6 +97,11 @@ if (request_headers.query.raw || romtype == "bf0app") {
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
if (bf0app_update) {
|
||||
var nextpath = calculatedPath(data, request_path, (request_headers.query.numparts || null));
|
||||
if (nextpath != null) headers += "\nwtv-visit: " + nextpath;
|
||||
}
|
||||
else headers += "\nwtv-connection-close: true";
|
||||
sendToClient(socket, headers, data);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user