diff options
author | Alexandr Ilenko <AIlenko@IBS.RU> | 2022-08-22 18:33:14 +0300 |
---|---|---|
committer | Alexandr Ilenko <AIlenko@IBS.RU> | 2022-08-30 10:45:30 +0300 |
commit | f47ddcfeaa957dd6571b35e6ba7b761892f186db (patch) | |
tree | 4e825212486e6ce5f09c889cea316f75136e2193 | |
parent | 0444ab4658743504ddf12ddf911158aebf9037ae (diff) | |
download | webui-vue-f47ddcfeaa957dd6571b35e6ba7b761892f186db.tar.xz |
[SILABMC-280] Fix: use wsS only when httpS
-rw-r--r-- | src/store/plugins/WebSocketPlugin.js | 4 | ||||
-rw-r--r-- | src/views/Operations/Kvm/KvmConsole.vue | 8 | ||||
-rw-r--r-- | src/views/Operations/SerialOverLan/SerialOverLanConsole.vue | 6 | ||||
-rw-r--r-- | src/views/Operations/VirtualMedia/VirtualMedia.vue | 9 |
4 files changed, 12 insertions, 15 deletions
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js index cbdc9329..afad6718 100644 --- a/src/store/plugins/WebSocketPlugin.js +++ b/src/store/plugins/WebSocketPlugin.js @@ -22,7 +22,9 @@ const WebSocketPlugin = (store) => { process.env.VUE_APP_SUBSCRIBE_SOCKET_DISABLED === 'true' ? true : false; if (socketDisabled) return; const token = store.getters['authentication/token']; - ws = new WebSocket(`wss://${window.location.host}/subscribe`, [token]); + const url = new URL('/subscribe', window.location.href); + url.protocol = url.protocol.replace('http', 'ws'); + ws = new WebSocket(url, [token]); ws.onopen = () => { ws.send(JSON.stringify(data)); }; diff --git a/src/views/Operations/Kvm/KvmConsole.vue b/src/views/Operations/Kvm/KvmConsole.vue index c028a9fc..c9425cfd 100644 --- a/src/views/Operations/Kvm/KvmConsole.vue +++ b/src/views/Operations/Kvm/KvmConsole.vue @@ -105,12 +105,10 @@ export default { this.rfb = null; }, openTerminal() { + const url = new URL('/kvm/0', window.location.href); + url.protocol = url.protocol.replace('http', 'ws'); const token = this.$store.getters['authentication/token']; - this.rfb = new RFB( - this.$refs.panel, - `wss://${window.location.host}/kvm/0`, - { wsProtocols: [token] } - ); + this.rfb = new RFB(this.$refs.panel, url, { wsProtocols: [token] }); this.rfb.scaleViewport = true; this.rfb.clipViewport = true; diff --git a/src/views/Operations/SerialOverLan/SerialOverLanConsole.vue b/src/views/Operations/SerialOverLan/SerialOverLanConsole.vue index 694083fd..6b84ab85 100644 --- a/src/views/Operations/SerialOverLan/SerialOverLanConsole.vue +++ b/src/views/Operations/SerialOverLan/SerialOverLanConsole.vue @@ -91,9 +91,9 @@ export default { openTerminal() { const token = this.$store.getters['authentication/token']; - this.ws = new WebSocket(`wss://${window.location.host}/console0`, [ - token, - ]); + const url = new URL('/console0', window.location.href); + url.protocol = url.protocol.replace('http', 'ws'); + this.ws = new WebSocket(url, [token]); // Refer https://github.com/xtermjs/xterm.js/ for xterm implementation and addons. diff --git a/src/views/Operations/VirtualMedia/VirtualMedia.vue b/src/views/Operations/VirtualMedia/VirtualMedia.vue index 8a3d5add..bbf6eb39 100644 --- a/src/views/Operations/VirtualMedia/VirtualMedia.vue +++ b/src/views/Operations/VirtualMedia/VirtualMedia.vue @@ -136,12 +136,9 @@ export default { methods: { startVM(device) { const token = this.$store.getters['authentication/token']; - device.nbd = new NbdServer( - `wss://${window.location.host}${device.websocket}`, - device.file, - device.id, - token - ); + const url = new URL(device.websocket, window.location.href); + url.protocol = url.protocol.replace('http', 'ws'); + device.nbd = new NbdServer(url, device.file, device.id, token); device.nbd.socketStarted = () => this.successToast(this.$t('pageVirtualMedia.toast.serverRunning')); device.nbd.errorReadingFile = () => |