Mercurial > hg > rlgwebd
diff rlgterm.js @ 201:f3843245a35e
Initial support for TLS.
RLGWebD now serves via encrypted connections on port 8081.
The client-side script now uses secure WebSockets if the page is being
accessed via HTTPS.
author | John "Elwin" Edwards |
---|---|
date | Sun, 01 Jan 2017 20:18:01 -0500 |
parents | 9758ca68e7f1 |
children |
line wrap: on
line diff
--- a/rlgterm.js Sat Apr 23 18:53:08 2016 -0400 +++ b/rlgterm.js Sun Jan 01 20:18:01 2017 -0500 @@ -396,7 +396,10 @@ } if (statsock) return; - statsock = new WebSocket("ws://" + window.location.host + "/status"); + var wsproto = "ws://"; + if (window.location.protocol == "https:") + wsproto = "wss://"; + statsock = new WebSocket(wsproto + window.location.host + "/status"); statsock.onmessage = function (ev) { var msg; try { @@ -618,7 +621,10 @@ if (!window.WebSocket) { return; } - var sockurl = "ws://" + window.location.host + "/play/" + game.uname; + var wsproto = "ws://"; + if (window.location.protocol == "https:") + wsproto = "wss://"; + var sockurl = wsproto + window.location.host + "/play/" + game.uname; sockurl += "?key=" + sessionStorage.getItem("lcred") + "&w=80&h=24"; ws = new WebSocket(sockurl); ws.onopen = function (event) { @@ -653,7 +659,10 @@ function startwatching(tag) { if (session.connect) return; - var sockurl = "ws://" + window.location.host + "/watch/" + tag; + var wsproto = "ws://"; + if (window.location.protocol == "https:") + wsproto = "wss://"; + var sockurl = wsproto + window.location.host + "/watch/" + tag; var ws = new WebSocket(sockurl); ws.onopen = function (event) { session.connect = true;