v0.9.13
- wtv-cookie support - further development will be in dev branch (may rebase alot) - compression not yet ready, leave it disabled - update: do not delete WTVSec on last socket, instead recreate on prereg - update: clean up SSID session data only if client is not seen for 3 minutes - update: add shouldWeCompress() function - update: tweak lzpf (still corrupted) - update: rename wtv-setup:/get to wtv-setup:/get-settings - update: add additional headers to wtv-setup:/get-settings - update: add initial blank wtv-music:/get-playlist - update wtv-tricks system - Info now shows Guest Mode or Subscriber Info - Implemented wtv-tricks:/unregister - Implemented wtv-tricks:/register - Show correct link in wtv-tricks:/tricks based on Guest Mode status - config.json: enable compression by default - WTVP does not use \r, so swapping the internal header's usage for now. May remove internal header in future update - lzpf: this doesn't fix anything but doesn't break it more either :) - renamed some functions - fixed some param documentation - added ConvertToBuffer function - WTVSec Updates - optimize WordArray to Buffer functions - update documentation in WTVSec - update WTVSec barrowed function in WTVLzpf - removed NewRC4Session, was a pointless alias to SecureOn
This commit is contained in:
@@ -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) {
|
||||
@@ -197,6 +214,19 @@ class WTVClientSessionData {
|
||||
}
|
||||
|
||||
|
||||
unregisterBox() {
|
||||
try {
|
||||
if (this.fs.lstatSync(this.session_storage + this.path.sep + this.ssid + ".json")) {
|
||||
return this.fs.unlinkSync(this.session_storage + this.path.sep + this.ssid + ".json");
|
||||
this.session_store = {};
|
||||
}
|
||||
} catch (e) {
|
||||
// Don't log error 'file not found', it just means the client isn't registered yet
|
||||
if (e.code != "ENOENT") console.error(" # Error deleting session data for", this.filterSSID(this.ssid), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
hasCap(cap) {
|
||||
if (this.capabilities) {
|
||||
return this.capabilities[cap] || false;
|
||||
|
||||
Reference in New Issue
Block a user