- major update: app.js: rewrite socket handling to stream data (fix issues POSTing with shoddy dialup, namely fix wtv-update:/sync issues)
 - update: wtv-home:/home: remove broken irc test, add links to DiskHax and VFatHax, remove URL Accessor form from MiniBrowser because it doesn't work
 - update: wtv-update:/sync: skip file if the Content-length matches the client and the client file is equal or newer, since client is not storing wtv-checksum for some reason. Client file time is set to when the client received the file last, and not actually when the file was modified on our end
 - update: wtv-head-waiter:/login-stage-two: offer prompt to minibrowser to go to home or willie
 - fix: clean up socket session data on socket error
 - code fixup: use `${}` instead of escaping string
 - app.js: better minibrowser session cleanup
 - update: http(s) proxy: do not send internal 'wtv-connection-close' header to client
 - fix: http(s) proxy: handle socks HostUnreachable error
 - fix: wtv-head-waiter:/login-stage-two: usernames longerfix: build 3833 crashes when `wtv-user-name` is too long
 - fix: wtv-log:/log
 - add: wtv-chat
 - add: wtv-setup
This commit is contained in:
zefie
2021-07-22 04:50:33 -04:00
parent 5b6d06241a
commit b0fd271dc3
22 changed files with 515 additions and 154 deletions

View File

@@ -0,0 +1,174 @@
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`;
if (request_headers.query.host && request_headers.query.port && request_headers.query.channel) {
data = `<html>
<display address="${request_headers.query.host}, port ${request_headers.query.port}, room ${request_headers.query.channel}">
<wtvchat
host="${request_headers.query.host}"
port="${request_headers.query.port}"
channel="#${request_headers.query.channel}"
bgcolor="#101C1E"
>
<head>
<title>
${request_headers.query.channel}
</title>
</head>
<body bgcolor="#101C1E" text="#A2ACB5" link="#CFC382" vlink="#E1EOE3" fontsize="medium" vspace=0 hspace=0>
<sidebar width=109>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=104 height=420 bgcolor=#69758B valign=top>
<table cellspacing=0 cellpadding=0>
<tr>
<td height=7 colspan=3>
<spacer type=vertical size=7>
<tr>
<td width=7>
<spacer type=horizontal size=7>
<td width=87 href="wtv-home:/home">
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
<td width=10>
<spacer type=horizontal size=10>
</table>
<spacer type=vertical size=6>
<table cellspacing=0 cellpadding=0 border=0>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valign=middle>
<td width=5>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valign=middle>
<td width=5>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valign=middle>
<table cellspacing=0 cellpadding=0 href="javascript:void(window.open('newChatChannel.panel'))" >
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E1EOE3>Create</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valign=middle>
<table cellspacing=0 cellpadding=0 href="client:ListChannelUsers" >
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E1EOE3>People</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
<tr>
<td width=10 height=26>
<td width=89 valign=middle>
<table cellspacing=0 cellpadding=0 href="client:OpenChatWhisperPanel" >
<tr>
<td height=1>
<tr>
<td><shadow><font sizerange=medium color=#E1EOE3>Whisper</font></shadow>
</table>
<td width=5>
<tr> <td bgcolor=#2E3A54 height=2 width=104 colspan=3>
</table>
<td width=5 bgcolor=#2E3A54>
</table>
</sidebar>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=451 colspan=2 align=center bgcolor=#2E3A54>
<spacer type=vertical size=13>
<tr>
<td><img src="wtv-chat:/images/top_corner_dark.jpg" width=8 height=8>
<td width=60>
<tr>
<td bgcolor=#101C1E width=13>
<spacer type=horizontal size=13>
<td bgcolor=#101C1E width=438 valign=top>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=105 height=9><spacer type=vertical size=9>
<td>
</table>
<tr>
<td colspan=2>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=375 height=25 bgcolor=#101C1E gradcolor=#3C4652 gradangle=90>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=366 valign=middle>&nbsp;&nbsp;
<blackface><font color=#D6D6D6> ${request_headers.query.channel}
</font></blackface><td>
<table cellspacing=0 cellpadding=0 border=0 bgcolor=#3C4652 gradcolor=#2E3A54 gradangle=90>
<tr>
<td><img src="wtv-chat:/images/widget.gif" width=16 height=16>
<td width=3>
<td width=54>
<spacer type=vertical size=1><br>
<a href="wtv-chat:/type"><font size=-1 color=#E7CE4A><b> Go to</b></font></a>
<td width=21>
<img src="wtv-chat:/images/widget.gif" width=16 height=16>
<td width=34>
</table>
</table>
</table>
<spacer type=vertical size=12> <table cellspacing=0 cellpadding=0>
<tr>
<td colspan=3 height=12>
<spacer type=vertical size=12> <tr>
<td abswidth=14>
<td>
<wtvchattranscript height=250 width=100%>
<td abswidth=20>
<tr>
<td height=10>
<tr>
<td>
<td colspan=2 height=2>
<spacer>
<tr>
<td height=1>
<tr>
<td>
<td colspan=2 height=2>
<spacer>
<tr>
<td height=6>
</table>
<table cellspacing=0 cellpadding=0 width=100%>
<tr>
<form action="client:ChatAddMessage" ONSUBMIT="this.chatinput.focus()">
<td abswidth=14>
<td>
<input id="chatinput" name="message" type="text" value="" size=32 bgcolor=262626 text=ffc342 cursor=cc9933 font=proportional selected autoactivate nohighlight>
<td align=right>
<font color=e7ce4a><shadow>
<input type=submit borderimage="file://ROM/Borders/ButtonBorder2.bif" value="Send" usestyle width=80>
<td abswidth=9>
</form>
<tr> <TD HEIGHT=8>
</table>
</body>
</html>`;
} else {
var errpage = doErrorPage("400 Chat requires host, port and channel arguments. Do not use the # on channels.");
headers = errpage[0];
data = errpage[1];
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

View File

@@ -123,7 +123,7 @@ hspace=0 vspace=0 fontsize="large">
<table cellspacing=0 cellpadding=0>
<tr>
<td width=104 height=74 valign=middle align=center bgcolor="3B3A4D">
<img src="`+ minisrv_config.config.service_logo +`" width=87 height=67>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
<td width=20 valign=top align=left bgcolor="3B3A4D">
<img src="wtv-flashrom:/ROMCache/Spacer.gif" width=1 height=1>
<td colspan=10 width=436 valign=middle align=left bgcolor="3B3A4D">
@@ -206,9 +206,6 @@ ${flashrom_message}
<td width=104 valign=middle align=center>
<td width=20 valign=middle align=center>
<td colspan=9 width=416 valign=top align=right>
<form action="client:gohome">
<input type="submit" value="Cancel Update" text="#CCCCCC" borderimage="file://ROM/Borders/ButtonBorder2.bif">
</form>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=306 valign=top align=left>

View File

@@ -23,7 +23,7 @@ hspace=0 vspace=0 fontsize="large">
<table cellspacing=0 cellpadding=0>
<tr>
<td width=104 height=74 valign=middle align=center bgcolor="3B3A4D">
<img src="`+ minisrv_config.config.service_logo +`" width=87 height=67>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
<td width=20 valign=top align=left bgcolor="3B3A4D">
<img src="wtv-flashrom:/ROMCache/Spacer.gif" width=1 height=1>
<td colspan=10 width=436 valign=middle align=left bgcolor="3B3A4D">

View File

@@ -51,7 +51,7 @@ data = `<html>
<table cellspacing=0 cellpadding=0>
<tr>
<td width=104 height=74 valign=middle align=center bgcolor="3B3A4D">
<img src="`+ minisrv_config.config.service_logo +`" width=87 height=67>
<img src="${minisrv_config.config.service_logo}" width=87 height=67>
<td width=20 valign=top align=left bgcolor="3B3A4D">
<img src="wtv-flashrom:/ROMCache/Spacer.gif" width=1 height=1>
<td colspan=10 width=436 valign=middle align=left bgcolor="3B3A4D">

View File

@@ -16,17 +16,14 @@ if (socket.ssid !== null) {
if (request_headers["wtv-ticket"].length > 8) {
wtvsec_login.DecodeTicket(request_headers["wtv-ticket"]);
wtvsec_login.ticket_b64 = request_headers["wtv-ticket"];
//socket_sessions[socket.id].secure = true;
}
} else {
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)) {
if (challenge_response.toString(CryptoJS.enc.Base64) == client_challenge_response) {
console.log(" * wtv-challenge-response success for " + filterSSID(socket.ssid));
wtvsec_login.PrepareTicket();
//socket_sessions[socket.id].secure = true;
} else {
console.log(" * wtv-challenge-response FAILED for " + filterSSID(socket.ssid));
if (zdebug) console.log("Response Expected:", challenge_response.toString(CryptoJS.enc.Base64));
@@ -44,13 +41,13 @@ if (gourl) {
headers = `200 OK
Connection: Keep-Alive
wtv-open-isp-disabled: false
wtv-visit: `+ gourl + `
wtv-visit: ${gourl}
Content-type: text/html`;
data = '';
}
else {
var namerand = Math.floor(Math.random() * 100000);
var nickname = minisrv_config.config.service_name+'_Usr_' + namerand;
var nickname = (minisrv_config.config.service_name + '_' + namerand).substring(0, 16);
var userid = '1'+ Math.floor(Math.random() * 1000000000000000000);
var offline_user_list = CryptoJS.enc.Latin1.parse("<user-list>\n\t<user userid=\"" + userid + " user-name=\"" + nickname + "\" first-name=\"" + minisrv_config.config.service_name + "User \" last-name=\\" + namerand + "\" password=\"\" mail-enabled=\"true\" />\n</user-list>").toString(CryptoJS.enc.Base64);
data = '';
@@ -63,16 +60,16 @@ wtv-country: US
wtv-language-header: en-US,en
wtv-visit: client:closeallpanels
wtv-expire-all: client:closeallpanels
wtv-offline-user-list: `+ offline_user_list + `
wtv-offline-user-list: ${offline_user_list}
wtv-bypass-proxy: true
wtv-ticket: `+ wtvsec_login.ticket_b64 + `
wtv-ticket: ${wtvsec_login.ticket_b64}
wtv-messagewatch-checktimeoffset: off
wtv-input-timeout: 14400
wtv-connection-timeout: 90
wtv-fader-timeout: 900
wtv-ssl-log-url: wtv-log:/log
wtv-smartcard-inserted-message: Contacting service
user-id: `+ userid + `
user-id: ${userid}
wtv-transition-override: off
wtv-allow-dsc: true
wtv-messenger-enable: 0
@@ -80,12 +77,9 @@ wtv-noback-all: wtv-
wtv-service: reset
`+ getServiceString('all') + `
wtv-boot-url: wtv-1800:/preregister?relogin=true
`;
//wtv-ssl-certs-download-url: wtv-head-waiter:/ssl-cert.der
//wtv-ssl-certs-checksum: 473926DC1B11F635A6B920953FDCDE6A
headers += `wtv-user-name: `+ nickname + `
wtv-human-name: `+ nickname + `
wtv-irc-nick: `+ nickname + `
wtv-user-name: ${nickname}
wtv-human-name: ${nickname}
wtv-irc-nick: ${nickname}
wtv-home-url: wtv-home:/home?
wtv-domain: wtv.zefie.com
wtv-inactive-timeout: 0
@@ -102,6 +96,7 @@ wtv-demo-mode: 0
wtv-wink-deferrer-retries: 3
wtv-offline-mail-enable: false
wtv-name-server: 8.8.8.8
wtv-settings-url: wtv-setup:/get
wtv-visit: wtv-home:/splash?
Content-Type: text/html`;
}

View File

@@ -23,26 +23,31 @@ function go() {
}
</script>
<h2>Welcome to `+ z_title + `</h2>
<h3>Encryption Status: `+cryptstatus+`</h3>
Connection Speed: &rate;
<b>Encryption Status</b>: ${cryptstatus}<br>
<b>Connection Speed</b>: &rate;
<p>
<form name=access onsubmit="go()">
<ul>
<li><a href="client:relog">client:relog (direct)</a></li>
<li><a href="wtv-tricks:/blastcache?return_to=wtv-home:/home">Clear Cache</a></li>
<li><a href="wtv-flashrom:/willie">Ultra Willies</a></li>
<li><a href="wtv-flashrom:/willie" selected>Ultra Willies</a></li>
<li><a href="wtv-music:/demo/index">MIDI Music Demo</a></li>
<li><a href="client:diskhax">DiskHax</a> - <a href="client:vfathax">VFatHax</a></li>
<li>Old MSNTV DealerDemo: <a href="wtv-update:/DealerDemo">Download</a> ~ <a href="file://Disk/Demo/index.html">Access (after Download)</a></li>
<li><a href="http://duckduckgo.com/lite/">DuckDuckGo Lite</a></li>
<li><input name=url `;
<li><a href="http://duckduckgo.com/lite/">DuckDuckGo Lite</a></li>`
if (ssid_sessions[socket.ssid].get('wtv-needs-upgrade') != 'true') {
data += `<li><input name=url `;
if (request_headers.query.url) {
data += "value='" + unescape(request_headers.query.url)+"'";
if (request_headers.query.url) {
data += "value='" + unescape(request_headers.query.url) + "'";
}
data += `width=250 height=10 bgcolor=#444444 text=#ffdd33 cursor=#cc9933>
<input type=submit value="Access URL">
</form>`
}
data += `width=250 height=10 bgcolor=#444444 text=#ffdd33 cursor=#cc9933 selected>
<input type=submit value="Access URL">
</form></li>
</ul>`
data += "</li >\n</ul>";
if (fs.existsSync(service_vaults[0] + "/" + service_name + "/home.zefie.html")) {
data += fs.readFileSync(service_vaults[0] + "/" + service_name + "/home.zefie.html", { 'encoding': 'utf8' });

View File

@@ -2,7 +2,7 @@ headers = `200 OK
Connection: Keep-Alive
wtv-expire-all: wtv-
wtv-expire-all: http
Content-type: text/html`
Content-Type: text/html`
data = `<html>
<head>
@@ -15,7 +15,7 @@ data = `<html>
<center>
<spacer type=block height=88 width=21>
<img src="file://ROM/Images/spacer.gif" height=4><br>
<img src="`+ minisrv_config.config.service_splash_logo + `">
<img src="${minisrv_config.config.service_splash_logo}">
<br><br><br>
<p><br>
<p><br>
@@ -23,14 +23,13 @@ data = `<html>
<tr><td width=150>
Mini service
<tr><td>
zefie minisrv v`+ minisrv_config.version;
zefie minisrv v${minisrv_config.version}`;
if (getGitRevision()) {
data += ` (git ` + getGitRevision().substring(0,8) + `)`;
data += " (git " + getGitRevision().substring(0, 8) + ")";
}
data += `
<tr><td>&rate;
</table>
</center>
</body>
</html>
`;
</html>`;

View File

@@ -1,19 +1,18 @@
// write posted log data to disk. should be decrypted by this point (if it was encrypted) if the crypto stream didn't break
request_is_async = true;
data = '';
var fullpath = __dirname + "/ServiceLogPost/" + Math.floor(new Date().getTime() / 1000) + "_" + request_headers.query.type;
if (socket.ssid) fullpath += "_" + socket.ssid;
fullpath += ".txt";
fullpath = fullpath.replace(/\\/g, "/");
if (request_headers.post_data) {
headers = `200 OK
Connection: Keep-Alive
Content-length: 0`;
data = '';
var fullpath = __dirname + "/ServiceLogPost/" + Math.floor(new Date().getTime() / 1000) + "_" + request_headers.query.type;
if (socket.ssid) fullpath += "_" + socket.ssid;
fullpath += ".txt";
fullpath = fullpath.replace(/\\/g, "/");
var logdata_outstring = '';
Object.keys(request_headers.query).forEach(function (k) {
logdata_outstring += k + "=" + unescape(request_headers.query[k].toString()) + "\r\n";
@@ -35,7 +34,6 @@ Content-length: 0`;
Connection: Keep-Alive
Content-length: 0`;
data = '';
var logdata_outstring = '';
Object.keys(request_headers.query).forEach(function (k) {
logdata_outstring += k + "=" + unescape(request_headers.query[k].toString()) + "\r\n";

View File

@@ -0,0 +1,31 @@
headers = `200 OK
Content-Type: text/html`
var settings_obj = new Array();
settings_obj["from-server"] = 1;
settings_obj["setup-advanced-options"] = 0;
settings_obj["setup-play-bgm"] = 0;
settings_obj["setup-bgm-tempo"] = -1;
settings_obj["setup-bgm-volume"] = 100;
settings_obj["setup-background-color"] = "c6c6c6";
settings_obj["setup-font-sizes"] = "medium";
settings_obj["setup-in-stereo"] = 1;
settings_obj["setup-keyboard"] = "alphabetical";
settings_obj["setup-link-color"] = "2222bb";
settings_obj["setup-play-songs"] = 1;
settings_obj["setup-play-sounds"] = 1;
settings_obj["setup-text-color"] = 0;
settings_obj["setup-visited-color"] = "8822bb";
settings_obj["setup-japan-keyboard"] = "roman";
settings_obj["setup-japan-softkeyboard"] = "norm"
settings_obj["setup-chat-access-level"] = 0;
settings_obj["setup-chat-on-nontrusted-pages"] = 1;
settings_obj["setup-tv-chat-level"] = 2;
data = "";
Object.keys(settings_obj).forEach(function (k, v) {
data += k + "=" + escape(settings_obj[k]) + "&";
});
data = data.substring(0, (data.length - 1));

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -83,7 +83,7 @@ function processGroup(diskmap_primary_group, diskmap_group_data, diskmap_subgrou
if (!post_data_fileinfo[post_data_filecount]) post_data_fileinfo[post_data_filecount] = new Array();
if (post_data_line_name == "Last-modified") {
post_data_fileinfo[post_data_filecount][post_data_line_name] = (Date.parse(post_data_line_data) / 1000);
post_data_fileinfo[post_data_filecount][post_data_line_name] = (new Date(new Date(Date.parse(post_data_line_data)).toUTCString()) / 1000);
} else if (post_data_line_name == "Content-length") {
post_data_fileinfo[post_data_filecount][post_data_line_name] = parseInt(post_data_line_data);
}
@@ -107,14 +107,17 @@ function processGroup(diskmap_primary_group, diskmap_group_data, diskmap_subgrou
if (!fs.existsSync(post_match_file)) post_match_file = null;
});
var post_match_file_lstat = fs.lstatSync(post_match_file);
var post_match_result = post_data_fileinfo.find(el => el.file === diskmap_group_data.files[k].file) || null;
var file_in_postdata = function (post_file) {
return post_file.file === diskmap_group_data.files[k].file
}
var post_match_file_lstat = fs.lstatSync(post_match_file);
var post_match_result = post_data_fileinfo.find(file_in_postdata) || null;
var post_match_file_data = new Buffer.from(fs.readFileSync(post_match_file, {
encoding: null,
flags: 'r'
}));
diskmap_group_data.files[k]["Last-modified"] = (post_match_file_lstat.mtime / 1000);
diskmap_group_data.files[k]["Last-modified"] = (new Date(new Date(post_match_file_lstat.mtime).toUTCString()) / 1000);
diskmap_group_data.files[k]["Content-length"] = post_match_file_lstat.size;
diskmap_group_data.files[k]["wtv-checksum"] = CryptoJS.MD5(CryptoJS.lib.WordArray.create(post_match_file_data)).toString(CryptoJS.enc.Hex).toLowerCase();
if (!diskmap_group_data.files[k].display) diskmap_group_data.files[k].display = diskmap_group_data.display;
@@ -122,6 +125,9 @@ function processGroup(diskmap_primary_group, diskmap_group_data, diskmap_subgrou
if (post_match_result) {
// md5s match, so client doesn't need file
if (diskmap_group_data.files[k]['wtv-checksum'].toLowerCase() == post_match_result["wtv-checksum"]) return;
// last modified is equal to or newer than the last update, and file size match, so assume same file and client does not need it
else if ((post_match_result["Last-modified"] >= diskmap_group_data.files[k]["Last-modified"]) && (post_match_result["Content-length"] == diskmap_group_data.files[k]["Content-length"])) return;
// otherwise send to client
else wtv_download_list.push(diskmap_group_data.files[k]);
} else {
wtv_download_list.push(diskmap_group_data.files[k]);
@@ -170,12 +176,12 @@ if (request_headers.query.diskmap && request_headers.query.group && request_head
var errpage = doErrorPage(404,"The requested DiskMap does not exist.");
headers = errpage[0];
data = errpage[1];
console.log("wtv-update:/sync error", "could not find diskmap");
if (zdebug) console.log(" # wtv-update:/sync error", "could not find diskmap");
}
} else {
var errpage = doErrorPage(400);
headers = errpage[0];
data = errpage[1];
if (zdebug) console.log("wtv-update:/sync error", "missing query arguments");
if (zdebug) console.log(" # wtv-update:/sync error", "missing query arguments");
}