Files
minisrv/zefie_wtvp_minisrv/ServiceVault/wtv-log/log.js
zefie 6c479782e9 v0.9.1
- fix: throw proper error if wtv-update:/sync called without arguments
 - feature: Support to route all HTTP proxied requests over a SOCKS proxy (eg Tor or VPN)
 - feature: Psuedo-HTTPS (WebTV can now visit HTTPS URLs via proxy, but
     we do not use SSL encryption when sending back to the WebTV)
 - fix: header issue with login-stage-two.js
 - fix: encrypted request headers were shown despite verbosity level
 - update: wtv-update/sync: allow multiple groups in sync diskmap, fix md5 comparsion
 - update: wtv-home:/home: added connection speed
 - Renamed processSSID to filterSSID
 - Documented and rewrote some functions
2022-11-29 07:43:52 -05:00

54 lines
2.0 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.ssid) fullpath += "_" + socket.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 (minisrv_config.services[service_name].write_logs_to_disk) {
fs.writeFile(fullpath, logdata_outstring_hex, "Hex", function () {
if (!zquiet) console.log(" * Wrote POST log data from", filterSSID(socket.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 (minisrv_config.services[service_name].write_logs_to_disk) {
fs.writeFile(fullpath, logdata_outstring_hex, "Hex", function () {
if (!zquiet) console.log(" * Wrote GET log data from", filterSSID(socket.ssid), "for", socket.id);
sendToClient(socket, headers, data);
});
} else {
sendToClient(socket, headers, data);
}
}