Do not crash when the console URL cannot be found.
This commit is contained in:
parent
22ed022787
commit
5801b29ede
21
src/index.js
21
src/index.js
@ -304,6 +304,10 @@ const getVmConsoleUrl = (xo, id) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!url) {
|
||||||
|
throw new Error('VM console not found')
|
||||||
|
}
|
||||||
|
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,17 +324,16 @@ const setUpConsoleProxy = (webServer, xo) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = getVmConsoleUrl(xo, matches[1])
|
try {
|
||||||
if (!url) {
|
const url = getVmConsoleUrl(xo, matches[1])
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: lost connection due to VM restart is not detected.
|
// FIXME: lost connection due to VM restart is not detected.
|
||||||
webSocketServer.handleUpgrade(req, socket, head, connection => {
|
webSocketServer.handleUpgrade(req, socket, head, connection => {
|
||||||
wsProxy(connection, url, {
|
wsProxy(connection, url, {
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
} catch (_) {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user