Skip to content

Commit

Permalink
support wss (#110)
Browse files Browse the repository at this point in the history
Fixes #99
  • Loading branch information
lanwen authored Jun 2, 2018
1 parent 06a67cf commit c9ee25e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions web/src/components/Log/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {Component} from "react";
import {Terminal} from "xterm";
import {Link} from "react-router-dom";
import urlTo from "../../util/urlTo";
import isSecure from "../../util/isSecure"

import "xterm/dist/xterm.css";
import "./style.scss";
import colors from "ansi-256-colors";
Expand Down Expand Up @@ -49,7 +50,7 @@ export default class Log extends Component {
.distinctUntilChanged((prev, {origin}) => prev.origin === origin)
.map(({session}) => {
const wsProxyUrl = urlTo(window.location.href);
return `ws://${wsProxyUrl.host}/ws/logs/${session}`;
return `${isSecure(wsProxyUrl) ? 'wss' : 'ws'}://${wsProxyUrl.host}/ws/logs/${session}`;
})
.switchMap(ws => {
return Rx.Observable.defer(() => {
Expand Down
9 changes: 5 additions & 4 deletions web/src/components/VncCard/VncScreen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {Component} from "react";
import RFB from "@novnc/novnc/core/rfb";
import urlTo from "../../util/urlTo"
import isSecure from "../../util/isSecure"

import "./style.scss";

Expand Down Expand Up @@ -39,7 +40,7 @@ export default class VncScreen extends Component {
const port = VncScreen.defaultPort(link);

this.disconnect(this.rfb);
this.rfb = this.createRFB(link, port, session);
this.rfb = this.createRFB(link, port, session, isSecure(link));
}
}

Expand All @@ -52,7 +53,7 @@ export default class VncScreen extends Component {
const port = VncScreen.defaultPort(link);

this.disconnect(this.rfb);
this.rfb = this.createRFB(link, port, session);
this.rfb = this.createRFB(link, port, session, isSecure(link));
}
}

Expand All @@ -62,10 +63,10 @@ export default class VncScreen extends Component {
this.disconnect(this.rfb);
}

createRFB(link, port, session) {
createRFB(link, port, session, secure) {
const rfb = new RFB(
this.canvas,
`ws://${link.hostname}:${port}/ws/vnc/${session}`,
`${secure ? 'wss' : 'ws'}://${link.hostname}:${port}/ws/vnc/${session}`,
{
credentials: {
password: "selenoid"
Expand Down
3 changes: 3 additions & 0 deletions web/src/util/isSecure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function isSecure({protocol}) {
return protocol === "https:";
}

0 comments on commit c9ee25e

Please sign in to comment.