- FlashROM Support for LC2 and newer. - FlashROM system can handle local files, or proxy from server (default). No need to have a local FlashROM collection! - Added 'verbosity' configuration option - Update HTML Mode to async fileRead - Config option for sending tellyscripts or not - Config option to mask SSIDs in console log - Update wtv-home:/home and wtv-home:/zefie - Update .gitignore - Add wtv-music:/demo/index courtesy of MattMan69 - Update HTML Mode to async fileRead - Update Raw TXT Mode to async fileRead - Replaced .async.js feature with defining `request_is_async` in standard .js script - Cleaned up code a bit - Moved global var 'query' to 'request_headers.query' - Tidied ServiceDeps - Upgraded wtv-log:/log to async, now also logs query arguments, saves to .txt for easier reading.
54 lines
2.1 KiB
JavaScript
54 lines
2.1 KiB
JavaScript
// write posted log data to disk. should be decrypted by this point (if it was encrypted) if the crypto stream didn't break
|
|
|
|
request_is_async = true;
|
|
|
|
if (request_headers.post_data) {
|
|
headers = `200 OK
|
|
Connection: Keep-Alive
|
|
Content-length: 0`;
|
|
|
|
data = '';
|
|
var fullpath = __dirname + "/ServiceLogPost/" + Math.floor(new Date().getTime() / 1000) + "_" + request_headers.query.type;
|
|
if (socket_session_data[socket.id].ssid) fullpath += "_" + socket_session_data[socket.id].ssid;
|
|
fullpath += ".txt";
|
|
|
|
fullpath = fullpath.replace(/\\/g, "/");
|
|
|
|
var logdata_outstring = '';
|
|
Object.keys(request_headers.query).forEach(function (k) {
|
|
logdata_outstring += k + "=" + unescape(request_headers.query[k].toString()) + "\r\n";
|
|
});
|
|
logdata_outstring += "\r\n";
|
|
var logdata_outstring_hex = Buffer.from(logdata_outstring, 'utf8').toString('hex');
|
|
logdata_outstring_hex += request_headers.post_data.toString(CryptoJS.enc.Hex);
|
|
if (services_configured.services[service_name].write_logs_to_disk) {
|
|
fs.writeFile(fullpath, logdata_outstring_hex, "Hex", function () {
|
|
if (!zquiet) console.log(" * Wrote POST log data from", processSSID(socket_session_data[socket.id].ssid), "for", socket.id);
|
|
sendToClient(socket, headers, data);
|
|
});
|
|
} else {
|
|
sendToClient(socket, headers, data);
|
|
}
|
|
|
|
} else {
|
|
headers = `200 OK
|
|
Connection: Keep-Alive
|
|
Content-length: 0`;
|
|
|
|
data = '';
|
|
var logdata_outstring = '';
|
|
Object.keys(request_headers.query).forEach(function (k) {
|
|
logdata_outstring += k + "=" + unescape(request_headers.query[k].toString()) + "\r\n";
|
|
});
|
|
var logdata_outstring_hex = Buffer.from(logdata_outstring, 'utf8').toString('hex');
|
|
if (services_configured.services[service_name].write_logs_to_disk) {
|
|
fs.writeFile(fullpath, logdata_outstring_hex, "Hex", function () {
|
|
if (!zquiet) console.log(" * Wrote GET log data from", processSSID(socket_session_data[socket.id].ssid), "for", socket.id);
|
|
sendToClient(socket, headers, data);
|
|
});
|
|
} else {
|
|
sendToClient(socket, headers, data);
|
|
}
|
|
}
|
|
|