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
This commit is contained in:
zefie
2021-08-06 12:18:30 -04:00
parent 345f106b2c
commit ad16a04c55
9 changed files with 137 additions and 86 deletions

View File

@@ -18,16 +18,17 @@ if (socket.ssid) {
if (i > 0 && zdebug) console.log(" # Closed", i, "previous sockets for", filterSSID(socket.ssid));
}
}
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
if (zdebug) console.log(" # Recreating primary WTVSec login instance for", filterSSID(socket.ssid));
delete ssid_sessions[socket.ssid].data_store.wtvsec_login;
}
ssid_sessions[socket.ssid].data_store.wtvsec_login = new WTVSec();
ssid_sessions[socket.ssid].data_store.wtvsec_login.IssueChallenge();
ssid_sessions[socket.ssid].data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
ssid_sessions[socket.ssid].data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"] || 1);
} else {
console.log(" * Something bad happened (we don't know the client ssid???)");
var errpage = doErrorCode(400)
var errpage = doErrorPage(400)
headers = errpage[0];
data = errpage[1];
}

View File

@@ -79,7 +79,11 @@ wtv-service: reset
wtv-boot-url: wtv-1800:/preregister?relogin=true
wtv-human-name: ${nickname}
${ssid_sessions[socket.ssid].setIRCNick(nickname)}
wtv-home-url: wtv-home:/home?
wtv-home-url: wtv-home:/home?`
if (ssid_sessions[socket.ssid].get('wtv-need-upgrade') != 'true' && !request_headers.query.reconnect) {
headers += "\nwtv-settings-url: wtv-setup:/get-settings";
}
headers += `
wtv-domain: wtv.zefie.com
wtv-inactive-timeout: 0
wtv-connection-timeout: 90
@@ -94,11 +98,6 @@ wtv-log-url: wtv-log:/log
wtv-demo-mode: 0
wtv-wink-deferrer-retries: 3
wtv-offline-mail-enable: false
wtv-name-server: 8.8.8.8
`;
if (ssid_sessions[socket.ssid].get('wtv-need-upgrade') != 'true' && !request_headers.query.reconnect) {
headers += "wtv-settings-url: wtv-setup:/get\n";
}
headers += `wtv-visit: wtv-home:/splash?
wtv-visit: wtv-home:/splash?
Content-Type: text/html`;
}

View File

@@ -1,72 +1,59 @@
var challenge_response, challenge_header = '';
var challenge_response, challenge_header = "";
var gourl = "wtv-head-waiter:/login-stage-two?";
if (request_headers.query.relogin) gourl += "relogin=true";
if (request_headers.query.reconnect) gourl += "reconnect=true";
var send_to_relogin = true;
if (socket.ssid !== null) {
var wtvsec_login = ssid_sessions[socket.ssid].get("wtvsec_login");
if (request_headers["wtv-ticket"]) {
if (wtvsec_login.ticket_b64 == null) {
if (request_headers["wtv-ticket"].length > 8) {
wtvsec_login.DecodeTicket(request_headers["wtv-ticket"]);
wtvsec_login.ticket_b64 = request_headers["wtv-ticket"];
}
}
} else {
if (wtvsec_login) {
challenge_response = wtvsec_login.challenge_response;
var client_challenge_response = request_headers["wtv-challenge-response"] || null;
if (challenge_response && client_challenge_response) {
if (challenge_response.toString(CryptoJS.enc.Base64).substring(0, 85) == client_challenge_response.substring(0, 85)) {
console.log(" * wtv-challenge-response success for " + socket.ssid);
wtvsec_login.PrepareTicket();
} else {
challenge_header = "wtv-challenge: " + wtvsec_login.IssueChallenge();
if (socket.ssid) {
if (ssid_sessions[socket.ssid]) {
if (request_headers["wtv-ticket"]) {
if (ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64 == null) {
if (request_headers["wtv-ticket"].length > 8) {
ssid_sessions[socket.ssid].data_store.wtvsec_login.DecodeTicket(request_headers["wtv-ticket"]);
ssid_sessions[socket.ssid].data_store.wtvsec_login.ticket_b64 = request_headers["wtv-ticket"];
send_to_relogin = false;
}
} else {
challenge_header = "wtv-challenge: " + wtvsec_login.IssueChallenge();
}
} else {
wtvsec_login = new WTVSec();
}
if (ssid_sessions[socket.ssid].data_store.wtvsec_login) {
var client_challenge_response = request_headers["wtv-challenge-response"] || null;
if (challenge_response && client_challenge_response) {
if (challenge_response.toString(CryptoJS.enc.Base64).substring(0, 85) == client_challenge_response.substring(0, 85)) {
console.log(" * wtv-challenge-response success for " + socket.ssid);
ssid_sessions[socket.ssid].data_store.wtvsec_login.PrepareTicket();
send_to_relogin = false;
} else {
challenge_header = "wtv-challenge: " + ssid_sessions[socket.ssid].data_store.wtvsec_login.IssueChallenge();
send_to_relogin = false;
}
} else {
challenge_header = "wtv-challenge: " + ssid_sessions[socket.ssid].data_store.wtvsec_login.IssueChallenge();
send_to_relogin = false;
}
}
}
}
}
/*
if (request_headers) {
var cookiedata = {};
Object.keys(request_headers).forEach(function (k) {
switch (k) {
case "wtv-capability-flags":
case "wtv-system-version":
case "wtv-client-rom-type":
case "wtv-client-bootrom-version":
case "wtv-system-chipversion":
case "wtv-system-sysconfig":
case "wtv-system-cpuspeed":
cookiedata[k] = request_headers[k];
break;
}
});
}
*/
if (!send_to_relogin) {
if (challenge_header != '') {
headers = `200 OK
Connection: Keep-Alive
Expires: Wed, 09 Oct 1991 22:00:00 GMT
wtv-expire-all: wtv-head-waiter:
`+ getServiceString('wtv-log') + `
wtv-log-url: wtv-log:/log
${challenge_header}
wtv-log-url: wtv-log:/log`;
if (challenge_header != "") headers += "\n" + challenge_header;
headers += `
wtv-relogin-url: wtv-1800:/preregister?relogin=true
wtv-reconnect-url: wtv-1800:/preregister?reconnect=true
wtv-visit: ${gourl}
Content-type: text/html`;
data = '';
} else {
headers = `200 OK
Connection: Keep-Alive
Expires: Wed, 09 Oct 1991 22:00:00 GMT

View File

@@ -0,0 +1,4 @@
headers = `200 OK
Content-Type: text/html`;
data = '';

View File

@@ -1,4 +1,9 @@
headers = `200 OK
wtv-backgroundmusic-load-playlist: wtv-music:/get-playlist
wtv-printer-model: -1,-1
wtv-printer-pen: 0,0,1,0
wtv-printer-setup: 0,0,1,0
wtv-language-header: en-US,en
Content-Type: text/html`
var settings_obj = new Array();