fix(xo-web/vm/console): SSH/RDP URLs

Introduced by 2b0f1b6aa and e9f82558e.
This commit is contained in:
Julien Fontanet 2022-07-07 16:56:26 +02:00
parent 30fe9764ad
commit 16ca2f8da9
2 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@
- [Tasks] Fix tasks not displayed when running CR backup job [Forum#6038](https://xcp-ng.org/forum/topic/6038/not-seeing-tasks-any-more-as-admin) (PR [#6315](https://github.com/vatesfr/xen-orchestra/pull/6315))
- [Backup] Fix failing merge multiple VHDs at once (PR [#6317](https://github.com/vatesfr/xen-orchestra/pull/6317))
- [VM/Console] Fix _Connect with SSH/RDP_ when address is IPv6
### Packages to release

View File

@ -17,6 +17,9 @@ import { Col, Container, Row } from 'grid'
import { confirm, form } from 'modal'
import { CpuSparkLines, MemorySparkLines, NetworkSparkLines, XvdSparkLines } from 'xo-sparklines'
// add `[]` around the hostname if it's an IPv6 address
const formatHostname = h => (h.indexOf(':') !== -1 ? `[${h}]` : h)
class SendToClipboard extends Component {
state = { value: this.props.clipboard }
@ -90,7 +93,7 @@ export default class TabConsole extends Component {
}
_openSsh = (username = 'root') => {
window.location = `ssh://${encodeURIComponent(username)}@${this.props.vm.mainIpAddress}`
window.location = `ssh://${encodeURIComponent(username)}@${formatHostname(this.props.vm.mainIpAddress)}`
}
_openSshMore = async () => {
@ -111,7 +114,7 @@ export default class TabConsole extends Component {
}
_openRdp = () => {
window.location = `rdp://${this.props.vm.mainIpAddress}`
window.location = `rdp://${formatHostname(this.props.vm.mainIpAddress)}`
}
render() {