Skip to content

Commit

Permalink
consoles: Don't use listening address to connect to VNC
Browse files Browse the repository at this point in the history
The listening address is most likely 127.0.0.1 (libvirt default) or
0.0.0.0 (yolo config). Neither of these works remotely.

Let's tell the remote viewer some address that has a chance of
working. More complicated setups, like a bastion host or connecting
via SSH inside Cockpit, might not work because of networking routing
challanges, but at least we get better error messages like "No route
to host" etc.

Also, with the libvirt default of only listening on 127.0.0.1, no
remote connection will work. But again, we now at least get the
expected "Connection refused" error message.
  • Loading branch information
mvollmer committed Jan 17, 2025
1 parent 6dfb90b commit c6c3054
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/components/vm/consoles/consoles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,23 @@ class Consoles extends React.Component {
onDesktopConsoleDownload (type) {
const { vm } = this.props;
// fire download of the .vv file
domainDesktopConsole({ name: vm.name, id: vm.id, connectionName: vm.connectionName, consoleDetail: vm.displays.find(display => display.type == type) });
const consoleDetail = vm.displays.find(display => display.type == type);

let address;
if (cockpit.transport.host == "localhost") {
const app = cockpit.transport.application();
if (app.startsWith("cockpit+="))
address = app.substr(9);
else
address = window.location.hostname;
} else {
address = cockpit.transport.host;
const pos = address.indexOf("@");
if (pos >= 0)
address = address.substr(pos+1);
}

domainDesktopConsole({ name: vm.name, consoleDetail: Object.assign({}, consoleDetail, { address }) });
}

render () {
Expand Down

0 comments on commit c6c3054

Please sign in to comment.