-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
Hi,
I have the following code --
I run this on the remote machine which I want to access using - VNC
#!/usr/bin/env node
const GuacamoleLite = require('guacamole-lite');
const websocketOptions = {
port: 8080 // we will accept connections to this port
};
const guacdOptions = {
port: 4822 // port of guacd
};
const clientOptions = {
log: {
level: 'VERBOSE'
},
crypt: {
cypher: 'AES-256-CBC',
key: 'MySuperSecretKeyForParamsToken12'
}
};
const guacServer = new GuacamoleLite(websocketOptions, guacdOptions, clientOptions);
And then
I try to connect to it using below code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="">
<style></style>
<!-- Guacamole -->
<script type="text/javascript"
src="https://unpkg.com/browse/[email protected]/dist/guacamole-common.js"></script>
</head>
<body>
<!-- Display -->
<div id="display"></div>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.WebSocketTunnel("ws://<PUBLIC_IP_OF_MACHINE>:8080")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
console.log("Error :: ", error);
alert(error);
};
// Connect
guac.connect('token=<generated_token>');
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script>
<!-- Init -->
<script type="text/javascript"> /* <![CDATA[ */
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onmousedown =
mouse.onmouseup =
mouse.onmousemove = function(mouseState) {
guac.sendMouseState(mouseState);
};
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
/* ]]> */ </script>
</body>
</html>
In above code - <PUBLIC_IP_OF_MACHINE> - this is public IP of the machine which I want to access using VNC
and - <generated_token> - this is a token generated using the below script ---
const crypto = require('crypto');
const clientOptions = {
cypher: 'AES-256-CBC',
key: 'MySuperSecretKeyForParamsToken12'
}
const encrypt = (value) => {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(clientOptions.cypher, clientOptions.key, iv);
let crypted = cipher.update(JSON.stringify(value), 'utf8', 'base64');
crypted += cipher.final('base64');
const data = {
iv: iv.toString('base64'),
value: crypted
};
return new Buffer(JSON.stringify(data)).toString('base64');
};
console.log("Token : " + encrypt({
"connection": {
"type": "vnc",
"settings": {
"hostname": "<PUBLIC_IP_OF_MACHINE>",
"port": "5900",
"username": "pawan",
"password": "pawan"
}
}
}));
It works when -- above index.html file is served over http.
When I serve the above - index.html file over https and modify
this
var guac = new Guacamole.Client(
new Guacamole.WebSocketTunnel("ws://<PUBLIC_IP_OF_MACHINE>:8080")
);
as
var guac = new Guacamole.Client(
new Guacamole.WebSocketTunnel("ws://<PUBLIC_IP_OF_MACHINE>:8080")
);
I get the below error in Browser console -
wss -- guacamole-common.js:13108 WebSocket connection to 'wss://<PUBLIC_IP_OF_MACHINE>:8080/?token=<token>' failed: [email protected]:[email protected]:3336(anonymous)@?userId=9had87:50
Any help is much appreciated.
Metadata
Metadata
Assignees
Labels
No labels