wtv-flashrom fixes
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
var minisrv_service_file = true;
|
var minisrv_service_file = true;
|
||||||
|
|
||||||
var wtvflashrom;
|
|
||||||
request_is_async = true;
|
request_is_async = true;
|
||||||
|
|
||||||
if (!request_headers.query.path) {
|
if (!request_headers.query.path) {
|
||||||
@@ -12,12 +11,19 @@ if (!request_headers.query.path) {
|
|||||||
var request_path = request_headers.query.path;
|
var request_path = request_headers.query.path;
|
||||||
|
|
||||||
// read flashrom header info into array using WTVFlashrom class
|
// read flashrom header info into array using WTVFlashrom class
|
||||||
wtvflashrom.getFlashromMeta(request_path, function (data) {
|
wtvflashrom.getFlashromMeta(request_path, function (data, headers) {
|
||||||
processLC2DownloadPage(request_headers.query.path, data, (request_headers.query.numparts ? request_headers.query.numparts : null));
|
processLC2DownloadPage(data, headers, (request_headers.query.numparts ? request_headers.query.numparts : null));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processLC2DownloadPage(path, flashrom_info, numparts = null) {
|
async function processLC2DownloadPage(flashrom_info, headers, numparts = null) {
|
||||||
|
if (typeof flashrom_info === 'string') {
|
||||||
|
// zefie_flashrom_server error
|
||||||
|
data = flashrom_info;
|
||||||
|
headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?";
|
||||||
|
sendToClient(socket, headers, data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
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.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
||||||
console.log(flashrom_info);
|
console.log(flashrom_info);
|
||||||
@@ -30,7 +36,8 @@ async function processLC2DownloadPage(path, flashrom_info, numparts = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-type: text/html`
|
Content-type: text/html
|
||||||
|
minisrv-no-mail-count: true`
|
||||||
|
|
||||||
data = `<html>
|
data = `<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -96,16 +103,10 @@ data += `
|
|||||||
<upgradeblock width=250 height=15
|
<upgradeblock width=250 height=15
|
||||||
nexturl="${flashrom_info.next_rompath}"
|
nexturl="${flashrom_info.next_rompath}"
|
||||||
errorurl="${service_name}:/lc2-download-failed?"
|
errorurl="${service_name}:/lc2-download-failed?"
|
||||||
blockurl="${flashrom_info.rompath}"`;
|
blockurl="${flashrom_info.rompath}
|
||||||
|
|
||||||
data += `
|
|
||||||
lastblock="${flashrom_info.is_last_part}"
|
lastblock="${flashrom_info.is_last_part}"
|
||||||
curblock="` + (flashrom_info.part_number + 1) + `"
|
curblock="${(flashrom_info.part_number + 1)}"${(flashrom_info.part_count) ? `
|
||||||
`;
|
totalblocks="${flashrom_info.part_count}">` : `>`}
|
||||||
if (flashrom_info.part_count) {
|
|
||||||
data += `totalblocks="${flashrom_info.part_count}"`;
|
|
||||||
}
|
|
||||||
data += `>
|
|
||||||
<font size="-1" color="#D6DFD0">
|
<font size="-1" color="#D6DFD0">
|
||||||
<br>
|
<br>
|
||||||
<img src="${service_name}:/ROMCache/Spacer.gif" width=2 height=10><br>
|
<img src="${service_name}:/ROMCache/Spacer.gif" width=2 height=10><br>
|
||||||
@@ -149,6 +150,7 @@ ${flashrom_info.message}
|
|||||||
} else {
|
} else {
|
||||||
var errpage = wtvshared.doErrorPage(400)
|
var errpage = wtvshared.doErrorPage(400)
|
||||||
headers = errpage[0];
|
headers = errpage[0];
|
||||||
|
headers += "\nminisrv-no-mail-count: true\nwtv-expire-all: wtv-flashrom:/get-lc2-page?";
|
||||||
data = errpage[1];
|
data = errpage[1];
|
||||||
}
|
}
|
||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ var romtype = session_data.get("wtv-client-rom-type");
|
|||||||
if (request_headers.query.numparts) url += "&numparts=" + request_headers.query.numparts;
|
if (request_headers.query.numparts) url += "&numparts=" + request_headers.query.numparts;
|
||||||
}
|
}
|
||||||
headers = "300 OK\n";
|
headers = "300 OK\n";
|
||||||
|
headers += "minisrv-no-mail-count: true\n";
|
||||||
headers += "wtv-visit: " + url + "\n";
|
headers += "wtv-visit: " + url + "\n";
|
||||||
headers += "Location: " + url + "\n";
|
headers += "Location: " + url + "\n";
|
||||||
headers += "Content-type: text/html";
|
headers += "Content-type: text/html";
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
var minisrv_service_file = true;
|
var minisrv_service_file = true;
|
||||||
|
|
||||||
headers = `200 OK
|
headers = `200 OK
|
||||||
Content-type: text/html`
|
Content-type: text/html
|
||||||
|
minisrv-no-mail-count: true
|
||||||
|
Connection: close`
|
||||||
|
|
||||||
data = `<html>
|
data = `<html>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user