[go: nahoru, domu]

Skip to content

Commit

Permalink
Cleanup non-essential options from vnc_lite
Browse files Browse the repository at this point in the history
This is supposed to be a simple example, it shouldn't have this many
options. This commit removes the following options:
 * logging - the default level 'warn' is good enough
 * title - a weird thing to set from the query string anyway
 * token - not used by most setups
 * encrypt - looking at the URL is good enough
 * repeaterID - not used by most setups
 * shared - uncommon setting
 * resize - not supported by most servers

Note that the removal of 'encrypt' allows us to remove logic for
establishing a default port. The default port for wss is 443 and for ws
it's 80 anyway.
  • Loading branch information
samhed committed Aug 28, 2018
1 parent 8c2866d commit 51f9f00
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions vnc_lite.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
Connect parameters are provided in query string:
http://example.com/?host=HOST&port=PORT&encrypt=1
http://example.com/?host=HOST&port=PORT&scale=true
or the fragment:
http://example.com/#host=HOST&port=PORT&encrypt=1
http://example.com/#host=HOST&port=PORT&scale=true
-->
<title>noVNC</title>

Expand Down Expand Up @@ -150,36 +150,12 @@
document.getElementById('sendCtrlAltDelButton').onclick = sendCtrlAltDel;

// Read parameters specified in the URL (query string or fragment)
WebUtil.init_logging(WebUtil.getConfigVar('logging', 'warn'));
document.title = WebUtil.getConfigVar('title', 'noVNC');
// By default, use the host and port of server that served this file
var host = WebUtil.getConfigVar('host', window.location.hostname);
var port = WebUtil.getConfigVar('port', window.location.port);

// if port == 80 (or 443) then it won't be present in window.location
// and we have to set it manually
if (!port) {
if (window.location.protocol.substring(0,5) == 'https') {
port = 443;
}
else if (window.location.protocol.substring(0,4) == 'http') {
port = 80;
}
}

var password = WebUtil.getConfigVar('password', '');
var path = WebUtil.getConfigVar('path', 'websockify');

// If a token variable is passed in, set the parameter in a cookie.
// This is used by nova-novncproxy.
var token = WebUtil.getConfigVar('token', null);
if (token) {
// if token is already present in the path we should use it
path = WebUtil.injectParamIfMissing(path, "token", token);

WebUtil.createCookie('token', token, 1)
}

// | | | | | |
// | | | Connect | | |
// v v v v v v
Expand All @@ -189,8 +165,7 @@

// Build the websocket URL used to connect
var url;
if (WebUtil.getConfigVar('encrypt',
(window.location.protocol === "https:"))) {
if (window.location.protocol === "https:") {
url = 'wss';
} else {
url = 'ws';
Expand All @@ -203,9 +178,7 @@

// Creating a new RFB object will start a new connection
rfb = new RFB(document.body, url,
{ repeaterID: WebUtil.getConfigVar('repeaterID', ''),
shared: WebUtil.getConfigVar('shared', true),
credentials: { password: password } });
{ credentials: { password: password } });

// Add listeners to important events from the RFB module
rfb.addEventListener("connect", connected);
Expand All @@ -216,7 +189,6 @@
// Set parameters that can be changed on an active connection
rfb.viewOnly = WebUtil.getConfigVar('view_only', false);
rfb.scaleViewport = WebUtil.getConfigVar('scale', false);
rfb.resizeSession = WebUtil.getConfigVar('resize', false);
})();
</script>
</head>
Expand Down

0 comments on commit 51f9f00

Please sign in to comment.