mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
F OpenNebula/one#3951: Guacamole lite integration (#229)
* Error management VMRC * Guacamole server within fireeedge server * Rename config file (fireedge-server.conf) Signed-off-by: Jorge Lobo <jlobo@opennebula.io>
This commit is contained in:
parent
52ccdc307a
commit
91677bd7b8
@ -26,3 +26,8 @@ LIMIT_TOKEN:
|
||||
VMRC:
|
||||
TARGET: 'http://opennebula.io'
|
||||
TOKENS_PATH: '/var/lib/one/sunstone_vnc_tokens/vmrc'
|
||||
|
||||
# Guacamole
|
||||
# GUACD:
|
||||
# PORT: 4822
|
||||
# HOST: '127.0.0.1'
|
@ -44,6 +44,7 @@
|
||||
"express": "^4.17.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"fuse.js": "^6.4.1",
|
||||
"guacamole-lite": "^0.6.3",
|
||||
"helmet": "^3.23.3",
|
||||
"http": "0.0.1-security",
|
||||
"http-proxy-middleware": "^1.0.5",
|
||||
|
@ -43,6 +43,7 @@ const {
|
||||
} = require('./routes/entrypoints');
|
||||
const { oneHooks } = require('./routes/websockets/zeromq');
|
||||
const { vmrcUpgrade } = require('./routes/websockets/vmrc');
|
||||
const { guacamole } = require('./routes/websockets/guacamole');
|
||||
const { messageTerminal, getConfig } = require('./utils');
|
||||
|
||||
const app = express();
|
||||
@ -115,3 +116,4 @@ appServer.listen(port, () => {
|
||||
messageTerminal(config);
|
||||
});
|
||||
vmrcUpgrade(appServer);
|
||||
guacamole(appServer);
|
||||
|
47
src/fireedge/src/routes/websockets/guacamole/index.js
Normal file
47
src/fireedge/src/routes/websockets/guacamole/index.js
Normal file
@ -0,0 +1,47 @@
|
||||
const { console } = require('window-or-global');
|
||||
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
const GuacamoleLite = require('guacamole-lite');
|
||||
const { getConfig } = require('../../../utils/yml');
|
||||
const { clientOptions, clientCallbacks } = require('./options');
|
||||
|
||||
const appConfig = getConfig();
|
||||
const guacd = appConfig.GUACD || {};
|
||||
const guacdPort = guacd.PORT || 4822;
|
||||
const guacdHost = guacd.HOST || '127.0.0.1';
|
||||
|
||||
const endpoint = '/guacamole';
|
||||
const guacamole = appServer => {
|
||||
if (
|
||||
appServer &&
|
||||
appServer.constructor &&
|
||||
appServer.constructor.name &&
|
||||
appServer.constructor.name === 'Server'
|
||||
) {
|
||||
// eslint-disable-next-line no-new
|
||||
new GuacamoleLite(
|
||||
{ server: appServer, path: endpoint }, // server fireedge
|
||||
{ host: guacdHost, port: guacdPort }, // guacD
|
||||
clientOptions,
|
||||
clientCallbacks
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
endpoint,
|
||||
guacamole
|
||||
};
|
27
src/fireedge/src/routes/websockets/guacamole/options.js
Normal file
27
src/fireedge/src/routes/websockets/guacamole/options.js
Normal file
@ -0,0 +1,27 @@
|
||||
const clientOptions = {
|
||||
crypt: {
|
||||
cypher: 'AES-256-CBC',
|
||||
key: 'LSIOGCKYLSIOGCKYLSIOGCKYLSIOGCKY'
|
||||
},
|
||||
allowedUnencryptedConnectionSettings: {
|
||||
rdp: ['width', 'height', 'dpi'],
|
||||
vnc: ['width', 'height', 'dpi'],
|
||||
ssh: ['color-scheme', 'font-name', 'font-size', 'width', 'height', 'dpi'],
|
||||
telnet: ['color-scheme', 'font-name', 'font-size', 'width', 'height', 'dpi']
|
||||
},
|
||||
log: { verbose: false }
|
||||
};
|
||||
|
||||
const callbacks = {
|
||||
processConnectionSettings: (settings, callback) => {
|
||||
if (settings.expiration && settings.expiration < Date.now()) {
|
||||
return callback(new Error('Token expired'));
|
||||
}
|
||||
return callback(null, settings);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
clientOptions,
|
||||
callbacks
|
||||
};
|
@ -16,13 +16,15 @@ const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
const { readFileSync } = require('fs-extra');
|
||||
const { getConfig } = require('../../../utils/yml');
|
||||
const { messageTerminal } = require('../../../utils/general');
|
||||
const { console } = require('window-or-global');
|
||||
|
||||
const appConfig = getConfig();
|
||||
const vmrcData = appConfig.VMRC || {};
|
||||
|
||||
const endpoint = '/vmrc';
|
||||
const url = vmrcData.TARGET || '';
|
||||
const config = {
|
||||
color: 'red'
|
||||
};
|
||||
const vmrcProxy = createProxyMiddleware(endpoint, {
|
||||
target: url,
|
||||
changeOrigin: false,
|
||||
@ -30,20 +32,23 @@ const vmrcProxy = createProxyMiddleware(endpoint, {
|
||||
secure: /^(https):\/\/[^ "]+$/.test(url),
|
||||
logLevel: 'debug',
|
||||
pathRewrite: path => path.replace(endpoint, '/ticket'),
|
||||
onError: err => {
|
||||
config.type = err.message;
|
||||
config.message = 'Error connection : %s';
|
||||
messageTerminal(config);
|
||||
},
|
||||
// eslint-disable-next-line consistent-return
|
||||
router: req => {
|
||||
if (req && req.url) {
|
||||
const ticket = req.url.split('/')[2];
|
||||
const ticket = req.url.split('/')[2] || '';
|
||||
try {
|
||||
const esxi = readFileSync(
|
||||
`${vmrcData.TOKENS_PATH || ''}/${ticket}`
|
||||
).toString();
|
||||
return esxi;
|
||||
} catch (error) {
|
||||
const config = {
|
||||
color: 'red',
|
||||
type: error.message,
|
||||
message: 'Error read vmrc token: %s'
|
||||
};
|
||||
config.type = error.message;
|
||||
config.message = 'Error read vmrc token: %s';
|
||||
messageTerminal(config);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ const defaults = {
|
||||
HOST: defaultIp,
|
||||
PORT: 2474
|
||||
},
|
||||
defaultConfigFile: `${__dirname}/../config.yml`,
|
||||
defaultConfigFile: `${__dirname}/../fireedge-server.conf`,
|
||||
defaultTypeLog: 'prod',
|
||||
defaultWebpackMode: 'development',
|
||||
defaultWebpackDevTool: 'inline-source-map',
|
||||
|
Loading…
Reference in New Issue
Block a user