Clean up session info into a class
This commit is contained in:
@@ -1,37 +1,38 @@
|
||||
if (socket_session_data[socket.id].ssid != null && !getSessionData(socket_session_data[socket.id].ssid, 'wtvsec_login')) {
|
||||
if (socket.ssid != null && !ssid_sessions[socket.ssid].get("wtvsec_login")) {
|
||||
var wtvsec_login = new WTVSec();
|
||||
wtvsec_login.IssueChallenge();
|
||||
wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
|
||||
setSessionData(socket_session_data[socket.id].ssid, 'wtvsec_login', wtvsec_login)
|
||||
} else {
|
||||
var wtvsec_login = getSessionData(socket_session_data[socket.id].ssid, 'wtvsec_login')
|
||||
ssid_sessions[socket.ssid].set("wtvsec_login", wtvsec_login);
|
||||
} else if (socket.ssid != null) {
|
||||
var wtvsec_login = ssid_sessions[socket.ssid].get("wtvsec_login");
|
||||
}
|
||||
|
||||
var prereg_contype = "text/html";
|
||||
if (wtvsec_login) {
|
||||
var prereg_contype = "text/html";
|
||||
|
||||
// if relogin, skip tellyscript
|
||||
if (request_headers.query.relogin) { // skip tellyscript
|
||||
wtvsec_login.ticket_b64 = null; // clear old ticket
|
||||
}
|
||||
// if relogin, skip tellyscript
|
||||
if (request_headers.query.relogin) { // skip tellyscript
|
||||
wtvsec_login.ticket_b64 = null; // clear old ticket
|
||||
}
|
||||
|
||||
// if relogin, skip tellyscript
|
||||
var romtype, file_path = null;
|
||||
if (!request_headers.query.relogin && minisrv_config.config.send_tellyscripts) {
|
||||
var romtype = getSessionData(socket_session_data[socket.id].ssid, 'wtv-client-rom-type');
|
||||
}
|
||||
// if relogin, skip tellyscript
|
||||
var romtype, file_path = null;
|
||||
if (!request_headers.query.relogin && minisrv_config.config.send_tellyscripts) {
|
||||
var romtype = ssid_sessions[socket.ssid].get("wtv-client-rom-type");
|
||||
}
|
||||
|
||||
switch (romtype) {
|
||||
case "US-LC2-disk-0MB-8MB":
|
||||
prereg_contype = "text/tellyscript";
|
||||
var file_path = __dirname + "/ServiceDeps/premade_tellyscripts/LC2/LC2_OISP_5555732_56k.tok";
|
||||
break;
|
||||
switch (romtype) {
|
||||
case "US-LC2-disk-0MB-8MB":
|
||||
prereg_contype = "text/tellyscript";
|
||||
var file_path = __dirname + "/ServiceDeps/premade_tellyscripts/LC2/LC2_OISP_5555732_56k.tok";
|
||||
break;
|
||||
|
||||
default:
|
||||
data = '';
|
||||
break;
|
||||
}
|
||||
default:
|
||||
data = '';
|
||||
break;
|
||||
}
|
||||
|
||||
headers = `200 OK
|
||||
headers = `200 OK
|
||||
Connection: Keep-Alive
|
||||
wtv-initial-key: ` + wtvsec_login.challenge_key.toString(CryptoJS.enc.Base64) + `
|
||||
Content-Type: `+ prereg_contype + `
|
||||
@@ -46,14 +47,20 @@ wtv-client-time-zone: GMT -0000
|
||||
wtv-client-time-dst-rule: GMT
|
||||
wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCString())) + ` GMT`;
|
||||
|
||||
if (file_path) {
|
||||
request_is_async = true;
|
||||
fs.readFile(file_path, null, function (err, file_read_data) {
|
||||
if (err) {
|
||||
var errmsg = doErrorCode(400);
|
||||
headers = errmsg[0];
|
||||
file_read_data = errmsg[1] + "\n" + err.toString();
|
||||
}
|
||||
sendToClient(socket, headers, file_read_data);
|
||||
});
|
||||
if (file_path) {
|
||||
request_is_async = true;
|
||||
fs.readFile(file_path, null, function (err, file_read_data) {
|
||||
if (err) {
|
||||
var errmsg = doErrorCode(400);
|
||||
headers = errmsg[0];
|
||||
file_read_data = errmsg[1] + "\n" + err.toString();
|
||||
}
|
||||
sendToClient(socket, headers, file_read_data);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log(" * Something bad happened (we don't know the client ssid???)");
|
||||
var errpage = doErrorCode(400)
|
||||
headers = errpage[0];
|
||||
data = errpage[1];
|
||||
}
|
||||
Reference in New Issue
Block a user