From b9d64de79ef06acb0734eb66b4d284226e4ca7c4 Mon Sep 17 00:00:00 2001 From: zefie Date: Tue, 12 Aug 2025 18:10:20 -0400 Subject: [PATCH] fix/optimize mailto, news, wtv-1800 --- .../includes/ServiceVault/mailto/catchall.js | 8 +-- .../includes/ServiceVault/news/catchall.js | 4 +- .../includes/ServiceVault/wtv-1800/noflash.js | 15 +++--- .../wtv-1800/offer-open-isp-suggest.js | 4 +- .../ServiceVault/wtv-1800/preregister.js | 52 +++++++++---------- .../ServiceVault/wtv-1800/unauthorized.js | 2 +- 6 files changed, 40 insertions(+), 45 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/mailto/catchall.js b/zefie_wtvp_minisrv/includes/ServiceVault/mailto/catchall.js index 6a3445d1..bb007a3e 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/mailto/catchall.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/mailto/catchall.js @@ -1,10 +1,10 @@ -var minisrv_service_file = true; +const minisrv_service_file = true; -var mailto = request_headers.request_url; +let mailto = request_headers.request_url; mailto = mailto.slice(mailto.indexOf(":") + 1); mailto = mailto.split("?")[0]; -var subject = request_headers.query.subject || ""; -var body = request_headers.query.body || ""; +const subject = request_headers.query.subject || ""; +const body = request_headers.query.body || ""; session_data.deleteSessionData("mail_draft"); session_data.deleteSessionData("mail_draft_attachments"); diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/news/catchall.js b/zefie_wtvp_minisrv/includes/ServiceVault/news/catchall.js index 8592b08e..1d750c72 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/news/catchall.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/news/catchall.js @@ -1,5 +1,5 @@ -var minisrv_service_file = true; +const minisrv_service_file = true; -var dest_url = "wtv-news:/news?group=" + request_headers.request_url.split(":")[1]; +const dest_url = "wtv-news:/news?group=" + request_headers.request_url.split(":")[1]; headers = `300 Moved Location: ${dest_url}` diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/noflash.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/noflash.js index 511075c3..97aff745 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/noflash.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/noflash.js @@ -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'; } diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/offer-open-isp-suggest.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/offer-open-isp-suggest.js index b8bb0262..a535838b 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/offer-open-isp-suggest.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/offer-open-isp-suggest.js @@ -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"; diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/preregister.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/preregister.js index b1fa82a4..a92e91e7 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/preregister.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/preregister.js @@ -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]; } \ No newline at end of file diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/unauthorized.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/unauthorized.js index 32015ce9..d158db70 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/unauthorized.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-1800/unauthorized.js @@ -1,4 +1,4 @@ -var minisrv_service_file = true; +const minisrv_service_file = true; headers = `200 OK Content-type: text/html