From 0215c19d1d1c0b08a30def4917d32aa58e7d4ba0 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 20 Sep 2018 14:47:39 +0200 Subject: [PATCH] feat(xo-server/proxy-console): work around missing host (#3435) Fixes #3432 --- CHANGELOG.md | 1 + packages/xo-server/src/proxy-console.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48204eb9d..297107aee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - [XOA updater] Fix issue where trial request would fail [#3407](https://github.com/vatesfr/xen-orchestra/issues/3407) (PR [#3412](https://github.com/vatesfr/xen-orchestra/pull/3412)) - [Backup NG logs] Fix log's value not being updated in the copy and report button [#3273](https://github.com/vatesfr/xen-orchestra/issues/3273) (PR [#3360](https://github.com/vatesfr/xen-orchestra/pull/3360)) - [Backup NG] Fix issue when *Delete first* was enabled for some of the remotes [#3424](https://github.com/vatesfr/xen-orchestra/issues/3424) (PR [#3427](https://github.com/vatesfr/xen-orchestra/pull/3427)) +- [VM/host consoles] Work around a XenServer/XCP-ng issue which lead to some consoles not working [#3432](https://github.com/vatesfr/xen-orchestra/issues/3432) (PR [#3435](https://github.com/vatesfr/xen-orchestra/pull/3435)) ### Released packages diff --git a/packages/xo-server/src/proxy-console.js b/packages/xo-server/src/proxy-console.js index 76b349943..22bc6b44b 100644 --- a/packages/xo-server/src/proxy-console.js +++ b/packages/xo-server/src/proxy-console.js @@ -7,12 +7,23 @@ const debug = createDebug('xo:proxy-console') export default function proxyConsole (ws, vmConsole, sessionId) { const url = parse(vmConsole.location) + let { hostname } = url + if (hostname === null || hostname === '') { + console.warn( + 'host is missing in console (%s) URI (%s)', + vmConsole.uuid, + vmConsole.location + ) + const { address } = vmConsole.$VM.$resident_on + console.warn(' using host address (%s) as fallback', address) + hostname = address + } let closed = false const socket = connect( { - host: url.hostname, + host: hostname, port: url.port || 443, rejectUnauthorized: false, }, @@ -21,7 +32,7 @@ export default function proxyConsole (ws, vmConsole, sessionId) { socket.write( [ `CONNECT ${url.path} HTTP/1.0`, - `Host: ${url.hostname}`, + `Host: ${hostname}`, `Cookie: session_id=${sessionId}`, '', '',