fix/optimize mailto, news, wtv-1800

This commit is contained in:
zefie
2025-08-12 18:10:20 -04:00
parent 5ae47352ed
commit b9d64de79e
6 changed files with 40 additions and 45 deletions

View File

@@ -1,18 +1,17 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
let wtvsec_login;
if (socket.ssid != null && !session_data.get("wtvsec_login")) {
var wtvsec_login = session_data.createWTVSecSession();
wtvsec_login = session_data.createWTVSecSession();
wtvsec_login.IssueChallenge();
if (request_headers["wtv-incarnation"]) wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
session_data.set("wtvsec_login", wtvsec_login);
} else if (socket.ssid != null) {
var wtvsec_login = session_data.get("wtvsec_login");
wtvsec_login = session_data.get("wtvsec_login");
}
if (wtvsec_login) {
headers = `200 OK
headers = `200 OK
Connection: Keep-Alive
minisrv-no-mail-count: true
wtv-initial-key: ` + wtvsec_login.challenge_key.toString(CryptoJS.enc.Base64) + `
@@ -28,7 +27,7 @@ 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`;
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
const file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
if (file_path) {
request_is_async = true;
@@ -41,7 +40,7 @@ wtv-client-date: `+ strftime("%a, %d %b %Y %H:%M:%S", new Date(new Date().toUTCS
}
} else {
console.log(" * Something bad happened (we don't know the client ssid???)");
headers=`500 missing ssid`
headers = '500 missing ssid';
}

View File

@@ -1,6 +1,6 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
var gourl = "wtv-1800:/finish-prereg?";
let gourl = "wtv-1800:/finish-prereg?";
if (request_headers.query.relogin) gourl += "relogin=true";

View File

@@ -1,8 +1,6 @@
var minisrv_service_file = true;
var gourl = "wtv-head-waiter:/login?";
const minisrv_service_file = true;
let gourl = "wtv-head-waiter:/login?";
let file_path = null;
if (session_data) {
if (session_data.loadSessionData() == true) {
@@ -14,7 +12,7 @@ if (session_data) {
}
if (session_data.data_store) {
if (session_data.data_store.sockets) {
var i = 0;
let i = 0;
session_data.data_store.sockets.forEach(function (k) {
if (typeof k != "undefined") {
if (k != socket) {
@@ -37,7 +35,7 @@ if (session_data) {
if (request_headers["wtv-incarnation"]) session_data.data_store.wtvsec_login.set_incarnation(request_headers["wtv-incarnation"]);
} else {
console.log(" * Something bad happened (we don't know the client ssid???)");
var errpage = wtvshared.doErrorPage(400)
const errpage = wtvshared.doErrorPage(400)
headers = errpage[0];
data = errpage[1];
}
@@ -49,19 +47,18 @@ if (request_headers.query.relogin && session_data.getSessionData("registered"))
if (request_headers.query.reconnect && session_data.getSessionData("registered")) gourl += "reconnect=true";
if (session_data.data_store.wtvsec_login) {
var prereg_contype = "text/html";
let prereg_contype = "text/html";
// if relogin and wtv-script-id != 0, skip tellyscript
session_data.set("wtv-open-access", (request_headers['wtv-open-access'] === "true") ? true : false);
var file_path = null;
var template = null;
var template_preprocessor = {};
var bf0app_update = false;
var romtype = session_data.get("wtv-client-rom-type");
var bootrom = parseInt(session_data.get("wtv-client-bootrom-version"));
var send_tellyscript = (minisrv_config.services[service_name].send_tellyscripts && !request_headers.query.relogin && !bootrom !== 0);
var wtv_script_id = parseInt(session_data.get("wtv-script-id"));
var wtv_script_mod = parseInt(session_data.get("wtv-script-mod"));
let template = null;
const template_preprocessor = {};
let bf0app_update = false;
const romtype = session_data.get("wtv-client-rom-type");
const bootrom = parseInt(session_data.get("wtv-client-bootrom-version"));
let send_tellyscript = (minisrv_config.services[service_name].send_tellyscripts && !request_headers.query.relogin && !bootrom !== 0);
const wtv_script_id = parseInt(session_data.get("wtv-script-id"));
const wtv_script_mod = parseInt(session_data.get("wtv-script-mod"));
if ((request_headers.query.reconnect || request_headers.query.relogin) && wtv_script_id != 0) send_tellyscript = false;
if (wtv_script_id !== 0 && wtv_script_mod !== 0) send_tellyscript = false;
if (!minisrv_config.services[service_name].send_tellyscript_to_mame) {
@@ -75,7 +72,6 @@ if (session_data.data_store.wtvsec_login) {
}
if (send_tellyscript) {
romtype = session_data.get("wtv-client-rom-type");
switch (romtype) {
case "US-LC2-disk-0MB-8MB":
case "US-LC2-disk-0MB-8MB-softmodem-CPU5230":
@@ -118,7 +114,7 @@ if (session_data.data_store.wtvsec_login) {
prereg_contype = "text/tellyscript";
// if wtv-open-access: true then client expects OpenISP
template = wtvshared.getServiceDep("/wtv-1800/tellyscripts/base.template.tsf")
template_preprocessor = { 'CLASSIC': true }
template_preprocessor.CLASSIC = true;
if (session_data.get("wtv-open-access")) template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.openisp.template.tsf");
else template += wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.normal.template.tsf");
//else file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
@@ -128,10 +124,10 @@ if (session_data.data_store.wtvsec_login) {
case "JP-Fiji":
prereg_contype = "text/tellyscript";
template_preprocessor = { 'FIJI': true }
template_preprocessor.FIJI = true;
// if wtv-open-access: true then client expects OpenISP
if (session_data.get("wtv-open-access")) var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
else var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
if (session_data.get("wtv-open-access")) file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
else file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/FIJI/dc_production_normal.tok", true);
break;
default:
@@ -141,7 +137,7 @@ if (session_data.data_store.wtvsec_login) {
if (socket.ssid.slice(0, 8) === "MSTVSIMU") {
prereg_contype = "text/dialscript";
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true);
file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/UTV/utv_hsd.tok", true);
}
}
@@ -150,8 +146,8 @@ if (session_data.data_store.wtvsec_login) {
// assume old classic in flash mode, override user setting and send tellyscript
// because it is required to proceed in flash mode
prereg_contype = "text/tellyscript";
var file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
var bf0app_update = true;
file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok", true);
bf0app_update = true;
session_data.set("bf0app_update", bf0app_update);
}
@@ -197,7 +193,7 @@ if (session_data.data_store.wtvsec_login) {
request_is_async = true;
fs.readFile(file_path, null, function (err, file_read_data) {
if (err) {
var errmsg = wtvshared.doErrorPage(400);
const errmsg = wtvshared.doErrorPage(400);
headers = errmsg[0];
file_read_data = errmsg[1] + "\n" + err.toString();
}
@@ -205,7 +201,7 @@ if (session_data.data_store.wtvsec_login) {
});
} else if (template) {
request_is_async = true;
telly = new WTVTellyScript(template, 2, template_preprocessor, session_data.get("wtv-open-access") ? 3 : 1); // dataState 2 = Untokenized
const telly = new WTVTellyScript(template, 2, template_preprocessor, session_data.get("wtv-open-access") ? 3 : 1); // dataState 2 = Untokenized
telly.setTemplateVars(minisrv_config.config.service_name, minisrv_config.services[service_name].dialin_number, minisrv_config.services[service_name].dns1ip, minisrv_config.services[service_name].dns2ip);
telly.minify();
telly.tokenize();
@@ -213,7 +209,7 @@ if (session_data.data_store.wtvsec_login) {
sendToClient(socket, headers, telly.packed_data);
}
} else {
var errpage = wtvshared.doErrorPage(400);
const errpage = wtvshared.doErrorPage(400);
headers = errpage[0];
data = errpage[1];
}

View File

@@ -1,4 +1,4 @@
var minisrv_service_file = true;
const minisrv_service_file = true;
headers = `200 OK
Content-type: text/html