- 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:
zefie
2021-08-08 18:11:33 -04:00
parent e09af90908
commit da37682a03
5 changed files with 27 additions and 10 deletions

View File

@@ -11,6 +11,7 @@ This open source server is in alpha status. Use at your own risk.
- Suports `.js` service files with synchronous or asynchronous requests
- Supports multiple simultaneous users
- WebTV-compatible HTTP(S) Proxy (via minisrv, or using an external proxy for enhanced features (such as [WebOne](https://github.com/atauenis/webone))
- WebTV Cookie (wtv-cookie) support for HTTP(s)
- Flashrom flashing support for all known units (including bf0app 'Old Classic')
- Can flash anything on [Ultra Willies](https://wtv.zefie.com/willie.php) with optional `use_zefie_server` flag set on `wtv-flashrom` service.
- `wtv-update:/sync` for Download-o-Rama style file downloading
@@ -29,8 +30,8 @@ This open source server is in alpha status. Use at your own risk.
### Feature Todo:
- wtv-lzpf support *(Milestone v1.0)*
- wtv-cookie full support *(Milestone v1.1)*
- TellyScript generation and/or manipulation without external dependancies
- wtv-cookie full support ***Done [v0.9.13](https://github.com/zefie/zefie_wtvp_minisrv/releases/tag/v0.9.13)***
- ~~Flashrom flashing for bf0app old classic~~ ***Done [v0.9.9](https://github.com/zefie/zefie_wtvp_minisrv/releases/tag/v0.9.9)***
- ~~SSID/IP black/whitelisting (including tying SSID to an IP or multiple IPs)~~ ***Done [v0.9.4](https://github.com/zefie/zefie_wtvp_minisrv/releases/tag/v0.9.4)***
- ~~Flashrom flashing functionality (at least for LC2 and higher)~~ ***Done [v0.8.0](https://github.com/zefie/zefie_wtvp_minisrv/releases/tag/v0.8.0)***

View File

@@ -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";
}

View File

@@ -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";

View File

@@ -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) {

View File

@@ -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",