Cleanup non-essential options from vnc_lite

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.
This commit is contained in:
Samuel Mannehed 2018-08-16 11:15:45 +02:00
parent 8c2866df36
commit 51f9f0098d
1 changed files with 4 additions and 32 deletions

View File

@ -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>
@ -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
@ -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';
@ -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);
@ -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>