fix insecure protocol for websockets

This commit is contained in:
Henrique Dias 2017-01-03 19:19:29 +00:00
parent f79d715558
commit 60e12c6f2d

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var tempID = "_fm_internal_temporary_id", var tempID = "_fm_internal_temporary_id",
ssl = (location.protocol === 'https:'),
templates = {}, templates = {},
selectedItems = [], selectedItems = [],
overlay, overlay,
@ -502,8 +503,10 @@ function searchEvent(event) {
url = removeLastDirectoryPartOf(url); url = removeLastDirectoryPartOf(url);
} }
let protocol = ssl ? 'wss:' : 'ws';
if(supported && user.AllowCommands) { if(supported && user.AllowCommands) {
let conn = new WebSocket(`ws://${url}?command=true`); let conn = new WebSocket(`${protocol}//${url}?command=true`);
conn.onopen = function () { conn.onopen = function () {
conn.send(value); conn.send(value);
@ -516,7 +519,7 @@ function searchEvent(event) {
conn.onclose = function (event) { conn.onclose = function (event) {
search.classList.remove('ongoing'); search.classList.remove('ongoing');
reloadListing(); listing.reload();
} }
return; return;
@ -525,7 +528,7 @@ function searchEvent(event) {
box.innerHTML = '<ul></ul>'; box.innerHTML = '<ul></ul>';
let ul = box.querySelector('ul'), let ul = box.querySelector('ul'),
conn = new WebSocket(`ws://${url}?search=true`); conn = new WebSocket(`${protocol}//${url}?search=true`);
conn.onopen = function () { conn.onopen = function () {
conn.send(value); conn.send(value);