From 012c0114e148486002f4c371321c0a15e59f08aa Mon Sep 17 00:00:00 2001 From: zefie Date: Mon, 26 Jul 2021 07:07:05 -0400 Subject: [PATCH] update: add 'setIRCNick()' function to WTVClientSessionData for ease of use update: add primative getMaxUsernameLength() to overcome username limitation in older builds update: wtv-chat:/home template --- .../ServiceVault/wtv-chat/MakeChatPage.js | 30 +--- .../ServiceVault/wtv-chat/home.html | 123 --------------- .../ServiceVault/wtv-chat/home.js | 144 ++++++++++++++++++ .../wtv-head-waiter/login-stage-two.js | 7 +- .../ServiceVault/wtv-home/home.js | 3 + zefie_wtvp_minisrv/WTVClientSessionData.js | 24 +++ zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj | 6 + 7 files changed, 185 insertions(+), 152 deletions(-) delete mode 100644 zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.html create mode 100644 zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.js diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-chat/MakeChatPage.js b/zefie_wtvp_minisrv/ServiceVault/wtv-chat/MakeChatPage.js index b75a4c37..22725453 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-chat/MakeChatPage.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-chat/MakeChatPage.js @@ -1,13 +1,6 @@ -headers = `200 OK`; - - -if (request_headers.query.nick) headers += ` -wtv-irc-nick: ${request_headers.query.nick} -wtv-user-nick: ${request_headers.query.nick}` -; - -headers += ` -Content-Type: text/html`; +headers = "200 OK"; +if (request_headers.query.nick) headers += "\n" + ssid_sessions[socket.ssid].setIRCNick(request_headers.query.nick); +headers += "\nContent-Type: text/html"; if (request_headers.query.host && request_headers.query.port && request_headers.query.channel) { data = ` @@ -46,16 +39,6 @@ ${request_headers.query.channel} - - - - - - - - - -
@@ -120,12 +103,9 @@ ${request_headers.query.channel}
- +
- Go to -
- - + Home
diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.html b/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.html deleted file mode 100644 index 2f14e323..00000000 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.html +++ /dev/null @@ -1,123 +0,0 @@ - - - -Chat Home - - - - - - - -
- - - -
- -
- - - - - -
- - - - -
-
- - - - - - - -
-
-
-
- - - - - - - -
- -
- -
- - - - -
- -
-
- - -
- - -
   - - - - -
- - -
-Chat Home -
- - -
-
-
- - - - - - - -
-
- -yo yo yo yo - -enter your nick... - - -
- - - - -
-
- - -
-
- - - -
- - - - - - - -
-
- - diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.js b/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.js new file mode 100644 index 00000000..72891537 --- /dev/null +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-chat/home.js @@ -0,0 +1,144 @@ +var irc_nick = ""; +headers = "200 OK"; +if (request_headers.query.nick) headers += "\n" + ssid_sessions[socket.ssid].setIRCNick(request_headers.query.nick); +else if (!ssid_sessions[socket.ssid].get("wtv-irc-nick")) ssid_sessions[socket.ssid].setIRCNick(minisrv_config.config.service_name + '_' + Math.floor(Math.random() * 100000)).substring(0, 16); +headers += "\nContent-Type: text/html"; + +var irc_nick = ssid_sessions[socket.ssid].get("wtv-irc-nick"); + +data = ` + + +Chat Home (Testing) + + + + + + + +
+ + + +
+ +
+ + + + + +
+ + + + + +
+
+ + + + +
+
Relogin +
+
+
+
+ + + + +
+
Home +
+
+
+
+ +
+
+
+
+ + + + + + +
+ +
+ +
+ + + + +
+ +
+
+ + +
+ + +
   + + + + +
+ + +
+
+
+ + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
Server:
Port:
Channel:
IRC Nick*:
+ +
+
+ +*Note: Once you are connected to the IRC Server, you cannot change your nickname until you disconnect. +What triggers the WebTV to disconnect from the chat server is not yet known, +it does maintain a connection to the IRC server, but leaves the channel, when you leave the chat page. +The connection times out after some time. Only then will any future attempts to change your name work. + +
+ +
+
+ +`; \ No newline at end of file diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-head-waiter/login-stage-two.js b/zefie_wtvp_minisrv/ServiceVault/wtv-head-waiter/login-stage-two.js index 5f4e23a1..0272707d 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-head-waiter/login-stage-two.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-head-waiter/login-stage-two.js @@ -47,8 +47,8 @@ Content-type: text/html`; } else { var namerand = Math.floor(Math.random() * 100000); - var nickname = (minisrv_config.config.service_name + '_' + namerand).substring(0, 16); - var userid = '1'+ Math.floor(Math.random() * 1000000000000000000); + var nickname = (minisrv_config.config.service_name + '_' + namerand) + var userid = '1' + Math.floor(Math.random() * 1000000000000000000); var offline_user_list = CryptoJS.enc.Latin1.parse("\n\t\n").toString(CryptoJS.enc.Base64); data = ''; headers = `200 OK @@ -77,9 +77,8 @@ wtv-noback-all: wtv- wtv-service: reset `+ getServiceString('all') + ` wtv-boot-url: wtv-1800:/preregister?relogin=true -wtv-user-name: ${nickname} wtv-human-name: ${nickname} -wtv-irc-nick: ${nickname} +${ssid_sessions[socket.ssid].setIRCNick(nickname)} wtv-home-url: wtv-home:/home? wtv-domain: wtv.zefie.com wtv-inactive-timeout: 0 diff --git a/zefie_wtvp_minisrv/ServiceVault/wtv-home/home.js b/zefie_wtvp_minisrv/ServiceVault/wtv-home/home.js index ca99e836..46edaa79 100644 --- a/zefie_wtvp_minisrv/ServiceVault/wtv-home/home.js +++ b/zefie_wtvp_minisrv/ServiceVault/wtv-home/home.js @@ -32,6 +32,9 @@ function go() {
  • Ultra Willies ~ Tricks Info
  • MIDI Music Demo
  • `; +if (ssid_sessions[socket.ssid].hasCap("client-can-do-chat")) { + data += "
  • IRC Chat Test
  • \n" +} if (ssid_sessions[socket.ssid].hasCap("client-has-disk")) { // only show disk stuff if client has disk data += "
  • DiskHax ~ VFatHax
  • \n"; diff --git a/zefie_wtvp_minisrv/WTVClientSessionData.js b/zefie_wtvp_minisrv/WTVClientSessionData.js index 547e4982..ba7b5dbf 100644 --- a/zefie_wtvp_minisrv/WTVClientSessionData.js +++ b/zefie_wtvp_minisrv/WTVClientSessionData.js @@ -22,6 +22,30 @@ class WTVClientSessionData { return false; } + getMaxUsernameLength() { + if (parseInt(this.data_store['wtv-system-version'] < 4000)) { + // older builds may crash with nicknames longer than 16 chars. + // actual build where support started is yet unknown + return 16; + } else { + // newer builds supported up to 32 chars, I think + return 32; + } + } + + setIRCNick(nick) { + // strip out unsupported chars + nick = nick.replace(/[^a-zA-Z0-9\-\_\`\^]/g, ""); + + // limit nick length based on build support + nick = nick.substring(0, this.getMaxUsernameLength()); + + // returns headers to send to client, while storing the new data in our session data. + this.data_store['wtv-user-name'] = nick; + this.data_store['wtv-irc-nick'] = nick; + return "wtv-irc-nick: " + nick + "\nwtv-user-nick: " + nick; + } + isMiniBrowser() { if (this.data_store['wtv-need-upgrade'] || this.data_store['wtv-used-8675309']) return true; return false; diff --git a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj index 2c248647..96f24d9f 100644 --- a/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj +++ b/zefie_wtvp_minisrv/zefie_wtvp_minisrv.njsproj @@ -32,6 +32,11 @@ + + + + + Code @@ -219,6 +224,7 @@ +