v0.9.13
- wtv-cookie support - further development will be in dev branch (may rebase alot) - compression not yet ready, leave it disabled
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
if (socket.ssid) {
|
||||
if (request_headers.post_data) {
|
||||
if (ssid_sessions[socket.ssid]) {
|
||||
ssid_sessions[socket.ssid].addCookie(cookie_data);
|
||||
ssid_sessions[socket.ssid].addCookie(request_headers.query.domain,request_headers.query.path,request_headers.query.expires,request_headers.query.cookie);
|
||||
headers = "200 OK\n";
|
||||
headers += "Content-Type: text/html";
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ if (request_headers.post_data) {
|
||||
if (request_headers.query.domain && request_headers.query.path) {
|
||||
if (socket.ssid) {
|
||||
if (ssid_sessions[socket.ssid]) {
|
||||
|
||||
data = ssid_sessions[socket.ssid].getCookieString(request_headers.query.domain, request_headers.query.path);
|
||||
headers = "200 OK\n";
|
||||
headers += "Content-Type: text/plain";
|
||||
|
||||
@@ -77,9 +77,23 @@ class WTVClientSessionData {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.session_store.cookies[this.countCookies()] = Object.assign({}, cookie_data);
|
||||
this.storeSessionData();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var cookie_index = -1;
|
||||
// see if we have a cookie for this domain/path
|
||||
Object.keys(this.session_store.cookies).forEach(function (k) {
|
||||
if (cookie_index >= 0) return;
|
||||
if (domain == self.session_store.cookies[k].domain && path == self.session_store.cookies[k].path) cookie_index = k;
|
||||
});
|
||||
// otherwise add a new one
|
||||
if (cookie_index == -1) cookie_index = this.countCookies();
|
||||
|
||||
this.session_store.cookies[cookie_index] = Object.assign({}, cookie_data);
|
||||
|
||||
// do not write file if user is not registered
|
||||
if (getSessionData('registered')) this.storeSessionData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -92,8 +106,8 @@ class WTVClientSessionData {
|
||||
if (self.session_store['cookies'][k].domain == domain &&
|
||||
self.session_store['cookies'][k].path == path) {
|
||||
|
||||
var current_epoch_utc = Math.floor(Date.toUTCString().getTime() / 1000);
|
||||
var cookie_expires_epoch_utc = Math.floor(Date.Parse(self.session_store['cookies'][k].expires).toUTCString().getTime());
|
||||
var current_epoch_utc = Date.parse((new Date()).toUTCString());
|
||||
var cookie_expires_epoch_utc = Date.parse(new Date(Date.parse(self.session_store['cookies'][k].expires)).toUTCString());
|
||||
if (cookie_expires_epoch_utc <= current_epoch_utc) self.deleteCookie(self.session_store['cookies'][k]);
|
||||
else result = self.session_store['cookies'][k];
|
||||
}
|
||||
@@ -103,11 +117,14 @@ class WTVClientSessionData {
|
||||
|
||||
getCookieString(domain, path) {
|
||||
var cookie_data = this.getCookie(domain, path);
|
||||
var outstring = "";
|
||||
/*
|
||||
var outstring = "";
|
||||
Object.keys(cookie_data).forEach(function (k) {
|
||||
outstring += k + "=" + escape(cookie_data[k]) + "&";
|
||||
});
|
||||
return outstring.substring(0, outstring.length - 1);
|
||||
*/
|
||||
return cookie_data.cookie;
|
||||
}
|
||||
|
||||
deleteCookie(domain, path = null) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "zefie_wtvp_minisrv",
|
||||
"version": "0.9.13-dev",
|
||||
"version": "0.9.13",
|
||||
"description": "WebTV Service (WTVP) Emulation Server",
|
||||
"main": "app.js",
|
||||
"homepage": "https://github.com/zefie/zefie_wtvp_minisrv",
|
||||
|
||||
Reference in New Issue
Block a user