From 63389812b5e1a04e0010ccd8c12ceb6ad4113d18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:09:05 +0000 Subject: [PATCH 01/11] Bump follow-redirects from 1.15.4 to 1.15.6 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.4 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.4...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 53189fde..8f5d991f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5417,9 +5417,9 @@ flatten@^1.0.2: integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg== follow-redirects@^1.0.0: - version "1.15.4" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" - integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== for-in@^1.0.2: version "1.0.2" From 20be9027fd11fd4f0934e053da118dfc5e273a50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:27:08 +0000 Subject: [PATCH 02/11] Bump express from 4.18.2 to 4.19.2 Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 53189fde..8cc59e03 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2989,7 +2989,25 @@ bluebird@^3.5.0, bluebird@^3.5.5: resolved "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== -body-parser@1.20.1, body-parser@^1.19.0: +body-parser@1.20.2: + version "1.20.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" + integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== + dependencies: + bytes "3.1.2" + content-type "~1.0.5" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.2" + type-is "~1.6.18" + unpipe "1.0.0" + +body-parser@^1.19.0: version "1.20.1" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668" integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw== @@ -3730,6 +3748,11 @@ content-type@~1.0.4: resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== +content-type@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== + convert-source-map@^1.5.1, convert-source-map@^1.7.0: version "1.8.0" resolved "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz" @@ -3742,10 +3765,10 @@ cookie-signature@1.0.6: resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== -cookie@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" - integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== +cookie@0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" + integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== cookie@^0.4.1, cookie@~0.4.1: version "0.4.2" @@ -5154,16 +5177,16 @@ expand-brackets@^2.1.4: to-regex "^3.0.1" express@^4.17.1: - version "4.18.2" - resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" - integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== + version "4.19.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" + integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== dependencies: accepts "~1.3.8" array-flatten "1.1.1" - body-parser "1.20.1" + body-parser "1.20.2" content-disposition "0.5.4" content-type "~1.0.4" - cookie "0.5.0" + cookie "0.6.0" cookie-signature "1.0.6" debug "2.6.9" depd "2.0.0" @@ -8985,6 +9008,16 @@ raw-body@2.5.1: iconv-lite "0.4.24" unpipe "1.0.0" +raw-body@2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + rc@^1.2.8: version "1.2.8" resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz" From bed98624cc47e7ff604a39a89ea54f5cac05e903 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:17:40 +0000 Subject: [PATCH 03/11] Bump tar from 6.1.11 to 6.2.1 Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.11 to 6.2.1. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-tar/compare/v6.1.11...v6.2.1) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 53189fde..248bf46f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7351,6 +7351,11 @@ minipass@^3.0.0, minipass@^3.1.0, minipass@^3.1.1, minipass@^3.1.3: dependencies: yallist "^4.0.0" +minipass@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-5.0.0.tgz#3e9788ffb90b694a5d0ec94479a45b5d8738133d" + integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ== + minizlib@^2.0.0, minizlib@^2.1.1: version "2.1.2" resolved "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz" @@ -10231,13 +10236,13 @@ tapable@^2.1.1, tapable@^2.2.0: integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== tar@^6.0.2, tar@^6.1.0: - version "6.1.11" - resolved "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== + version "6.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a" + integrity sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" - minipass "^3.0.0" + minipass "^5.0.0" minizlib "^2.1.1" mkdirp "^1.0.3" yallist "^4.0.0" From c12a7acb2cb2c8689c3fdb856249193902334156 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 07:52:40 +0000 Subject: [PATCH 04/11] Bump @angular/core from 9.0.0 to 12.2.17 Bumps [@angular/core](https://github.com/angular/angular/tree/HEAD/packages/core) from 9.0.0 to 12.2.17. - [Release notes](https://github.com/angular/angular/releases) - [Changelog](https://github.com/angular/angular/blob/main/CHANGELOG.md) - [Commits](https://github.com/angular/angular/commits/12.2.17/packages/core) --- updated-dependencies: - dependency-name: "@angular/core" dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 248bf46f..a4bb5e50 100644 --- a/yarn.lock +++ b/yarn.lock @@ -220,13 +220,13 @@ "@angular/core@9.0.0": version "9.0.0" - resolved "https://registry.npmjs.org/@angular/core/-/core-9.0.0.tgz" + resolved "https://registry.yarnpkg.com/@angular/core/-/core-9.0.0.tgz#227dc53e1ac81824f998c6e76000b7efc522641e" integrity sha512-6Pxgsrf0qF9iFFqmIcWmjJGkkCaCm6V5QNnxMy2KloO3SDq6QuMVRbN9RtC8Urmo25LP+eZ6ZgYqFYpdD8Hd9w== "@angular/core@^12.2.12": - version "12.2.13" - resolved "https://registry.yarnpkg.com/@angular/core/-/core-12.2.13.tgz#fc40acbdcee5c5878bd249ddc0d643be724076c3" - integrity sha512-tZ5nAnmOi418JDaJIFiiP9z2JrluMJZvUvXO4QDUs52BXaL2yuP7MJ2LczWOVJXrBLZXeZGfjDjZmaFPA24grg== + version "12.2.17" + resolved "https://registry.yarnpkg.com/@angular/core/-/core-12.2.17.tgz#15c70a46de66f3d9500b2dc8e233f30328e83ad0" + integrity sha512-XUvTgU0D8XqNH5Y7UlTMk/XjUQaEGC0kZxhw/QSSQr65WrXtXmcD4d8Cg84TJ52uGXmf7IAruKvtbvu1Mbmvug== dependencies: tslib "^2.2.0" From 80239229aa18bf8185b4a0a8ce50ea468ddbc281 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 01:29:26 +0000 Subject: [PATCH 05/11] Bump ejs from 3.1.8 to 3.1.10 Bumps [ejs](https://github.com/mde/ejs) from 3.1.8 to 3.1.10. - [Release notes](https://github.com/mde/ejs/releases) - [Commits](https://github.com/mde/ejs/compare/v3.1.8...v3.1.10) --- updated-dependencies: - dependency-name: ejs dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 248bf46f..d8927a77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4733,9 +4733,9 @@ eev@^0.1.5: integrity sha512-U7+up/+0JaC+ffyrMicGDzb+j2Q04Fy22tKK1Xh6hHFWdVtXwoBF8M2DwFofwsJzJcs3W3NPDvmxcMak5/iQaA== ejs@^3.1.6: - version "3.1.8" - resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.8.tgz#758d32910c78047585c7ef1f92f9ee041c1c190b" - integrity sha512-/sXZeMlhS0ArkfX2Aw780gJzXSMPnKjtspYZv+f3NiKLlubezAHDU5+9xz6gd3/NhG3txQCo6xlglmTS+oTGEQ== + version "3.1.10" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" + integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA== dependencies: jake "^10.8.5" From e9487c5ada42820ddeaa96375b3d9a476bd027dc Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 15:18:59 +0700 Subject: [PATCH 06/11] Create protocol handler service --- src/app/app.module.ts | 2 + ...console-device-action-browser.component.ts | 39 ++------------- .../log-console/log-console.component.ts | 8 ++-- .../project-map/project-map.component.ts | 12 +++-- src/app/services/packet-capture.service.ts | 11 +++-- src/app/services/protocol-handler.service.ts | 48 +++++++++++++++++++ 6 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 src/app/services/protocol-handler.service.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 1769c4db..9b895320 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -238,6 +238,7 @@ import { NodeService } from './services/node.service'; import { NodeConsoleService } from './services/nodeConsole.service'; import { NotificationService } from './services/notification.service'; import { PacketCaptureService } from './services/packet-capture.service'; +import { ProtocolHandlerService } from './services/protocol-handler.service'; import { PlatformService } from './services/platform.service'; import { ProjectService } from './services/project.service'; import { QemuConfigurationService } from './services/qemu-configuration.service'; @@ -538,6 +539,7 @@ import { RotationValidator } from './validators/rotation-validator'; ComputeService, TracengService, PacketCaptureService, + ProtocolHandlerService, NotificationService, Gns3vmService, ThemeService, diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index 57f5df01..c521be41 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -4,6 +4,8 @@ import { Node } from '../../../../../cartography/models/node'; import { Server } from '../../../../../models/server'; import { NodeService } from '../../../../../services/node.service'; import { ToasterService } from '../../../../../services/toaster.service'; +import { ProtocolHandlerService } from '../../../../../services/protocol-handler.service'; + import * as ipaddr from 'ipaddr.js'; @Component({ @@ -14,7 +16,7 @@ export class ConsoleDeviceActionBrowserComponent { @Input() server: Server; @Input() node: Node; - constructor(private toasterService: ToasterService, private nodeService: NodeService, private deviceService: DeviceDetectorService) {} + constructor(private toasterService: ToasterService, private nodeService: NodeService, private protocolHandlerService: ProtocolHandlerService) {} openConsole() { this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { @@ -23,31 +25,6 @@ export class ConsoleDeviceActionBrowserComponent { }); } - createHiddenIframe(target: Element, uri: string) { - const iframe = document.createElement("iframe"); - iframe.src = uri; - iframe.id = "hiddenIframe"; - iframe.style.display = "none"; - target.appendChild(iframe); - return iframe; - } - - openUriUsingFirefox(uri: string) { - var iframe = (document.querySelector("#hiddenIframe") as HTMLIFrameElement); - - if (!iframe) { - iframe = this.createHiddenIframe(document.body, "about:blank"); - } - - try { - iframe.contentWindow.location.href = uri; - } catch (e) { - if (e.name === "NS_ERROR_UNKNOWN_PROTOCOL") { - this.toasterService.error('Protocol handler does not exist'); - } - } - } - startConsole() { if (this.node.status !== 'started') { this.toasterService.error('This node must be started before a console can be opened'); @@ -60,8 +37,6 @@ export class ConsoleDeviceActionBrowserComponent { this.node.console_host = this.server.host; } - const device = this.deviceService.getDeviceInfo(); - try { var uri; var host = this.node.console_host; @@ -81,13 +56,7 @@ export class ConsoleDeviceActionBrowserComponent { this.toasterService.error('Supported console types are: telnet, vnc, spice and spice+agent.'); } - if (device.browser === "Firefox") { - // Use a hidden iframe otherwise Firefox will disconnect - // from the GNS3 controller websocket if we use location.assign() - this.openUriUsingFirefox(uri); - } else { - location.assign(uri); - } + this.protocolHandlerService.open(uri); } catch (e) { this.toasterService.error(e); diff --git a/src/app/components/project-map/log-console/log-console.component.ts b/src/app/components/project-map/log-console/log-console.component.ts index 59412210..1c3ed625 100644 --- a/src/app/components/project-map/log-console/log-console.component.ts +++ b/src/app/components/project-map/log-console/log-console.component.ts @@ -23,6 +23,7 @@ import { Server } from '../../../models/server'; import { HttpServer } from '../../../services/http-server.service'; import { NodeService } from '../../../services/node.service'; import { NodeConsoleService } from '../../../services/nodeConsole.service'; +import { ProtocolHandlerService } from '../../../services/protocol-handler.service'; import { ThemeService } from '../../../services/theme.service'; import { version } from '../../../version'; import { LogEventsDataSource } from './log-events-datasource'; @@ -70,6 +71,7 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { private projectWebServiceHandler: ProjectWebServiceHandler, private nodeService: NodeService, private nodesDataSource: NodesDataSource, + private protocolHandlerService: ProtocolHandlerService, private logEventsDataSource: LogEventsDataSource, private httpService: HttpServer, private themeService: ThemeService, @@ -230,15 +232,15 @@ export class LogConsoleComponent implements OnInit, AfterViewInit, OnDestroy { host = `[${host}]`; } if (node.console_type === 'telnet') { - location.assign( + this.protocolHandlerService.open( `gns3+telnet://${host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` ); } else if (node.console_type === 'vnc') { - location.assign( + this.protocolHandlerService.open( `gns3+vnc://${host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` ); } else if (node.console_type.startsWith('spice')) { - location.assign( + this.protocolHandlerService.open( `gns3+spice://${host}:${node.console}?name=${node.name}&project_id=${node.project_id}&node_id=${node.node_id}` ); } else if (node.console_type.startsWith('http')) { diff --git a/src/app/components/project-map/project-map.component.ts b/src/app/components/project-map/project-map.component.ts index 3f2ce336..3dfd32c3 100644 --- a/src/app/components/project-map/project-map.component.ts +++ b/src/app/components/project-map/project-map.component.ts @@ -67,6 +67,7 @@ import { SymbolService } from '../../services/symbol.service'; import { ThemeService } from '../../services/theme.service'; import { ToasterService } from '../../services/toaster.service'; import { ToolsService } from '../../services/tools.service'; +import { ProtocolHandlerService } from '../../services/protocol-handler.service'; import { AddBlankProjectDialogComponent } from '../projects/add-blank-project-dialog/add-blank-project-dialog.component'; import { ConfirmationBottomSheetComponent } from '../projects/confirmation-bottomsheet/confirmation-bottomsheet.component'; import { EditProjectDialogComponent } from '../projects/edit-project-dialog/edit-project-dialog.component'; @@ -173,8 +174,9 @@ export class ProjectMapComponent implements OnInit, OnDestroy { private title: Title, private nodeConsoleService: NodeConsoleService, private symbolService: SymbolService, + private protocolHandlerService: ProtocolHandlerService, private cd: ChangeDetectorRef, - private cfr: ComponentFactoryResolver, + private cfr: ComponentFactoryResolver, private injector: Injector ) {} @@ -229,7 +231,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { this.instance.instance.ngOnDestroy(); this.instance.destroy(); } - } + } } addSubscriptions() { @@ -975,7 +977,7 @@ export class ProjectMapComponent implements OnInit, OnDestroy { ) { this.toasterService.error('Project with running nodes cannot be exported.'); } else { - location.assign(this.projectService.getExportPath(this.server, this.project)); + this.protocolHandlerService.open(this.projectService.getExportPath(this.server, this.project)); } } @@ -990,8 +992,8 @@ export class ProjectMapComponent implements OnInit, OnDestroy { fileReader.onloadend = () => { let image = fileReader.result; - let svg = `\n\n\n`; this.drawingService .add(this.server, this.project.project_id, -(imageToUpload.width / 2), -(imageToUpload.height / 2), svg) diff --git a/src/app/services/packet-capture.service.ts b/src/app/services/packet-capture.service.ts index 642a3d72..d3ebb26e 100644 --- a/src/app/services/packet-capture.service.ts +++ b/src/app/services/packet-capture.service.ts @@ -2,14 +2,17 @@ import { Injectable } from '@angular/core'; import { Link } from '../models/link'; import { Project } from '../models/project'; import { Server } from '../models/server'; +import { ProtocolHandlerService } from './protocol-handler.service'; @Injectable() export class PacketCaptureService { - constructor() {} + + constructor(private protocolHandlerService: ProtocolHandlerService) {} startCapture(server: Server, project: Project, link: Link, name: string) { - location.assign( - `gns3+pcap://${server.host}:${server.port}?protocol=${server.protocol.slice(0, -1)}&project_id=${project.project_id}&link_id=${link.link_id}&project=${project.name}&name=${name}` - ); + + const uri = `gns3+pcap://${server.host}:${server.port}?protocol=${server.protocol.slice(0, -1)}&project_id=${project.project_id}&link_id=${link.link_id}&project=${project.name}&name=${name}`; + this.protocolHandlerService.open(uri); + } } diff --git a/src/app/services/protocol-handler.service.ts b/src/app/services/protocol-handler.service.ts new file mode 100644 index 00000000..70ca8384 --- /dev/null +++ b/src/app/services/protocol-handler.service.ts @@ -0,0 +1,48 @@ +import { Injectable } from '@angular/core'; +import { DeviceDetectorService } from 'ngx-device-detector'; +import { ToasterService } from './toaster.service'; + +@Injectable() +export class ProtocolHandlerService { + + constructor(private toasterService: ToasterService, private deviceService: DeviceDetectorService) {} + + createHiddenIframe(target: Element, uri: string) { + const iframe = document.createElement("iframe"); + iframe.src = uri; + iframe.id = "hiddenIframe"; + iframe.style.display = "none"; + target.appendChild(iframe); + return iframe; + } + + openUriUsingFirefox(uri: string) { + var iframe = (document.querySelector("#hiddenIframe") as HTMLIFrameElement); + + if (!iframe) { + iframe = this.createHiddenIframe(document.body, "about:blank"); + } + + try { + iframe.contentWindow.location.href = uri; + } catch (e) { + if (e.name === "NS_ERROR_UNKNOWN_PROTOCOL") { + this.toasterService.error('Protocol handler does not exist'); + } + } + } + + open(uri: string) { + + const device = this.deviceService.getDeviceInfo(); + + console.log("Launching external protocol handler with " + device.browser + ": " + uri) + if (device.browser === "Firefox") { + // Use a hidden iframe otherwise Firefox will disconnect + // from the GNS3 controller websocket if we use location.assign() + this.openUriUsingFirefox(uri); + } else { + location.assign(uri); + } + } +} From de058e175b0d16024b7c85cfc587b7d78892c90a Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 17:15:29 +0700 Subject: [PATCH 07/11] Fix tests --- src/app/app.module.ts | 2 +- .../project-map/log-console/log-console.component.spec.ts | 4 ++++ .../start-capture/start-capture.component.spec.ts | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9b895320..dcc6ac46 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -215,6 +215,7 @@ import { DefaultLayoutComponent } from './layouts/default-layout/default-layout. import { MATERIAL_IMPORTS } from './material.imports'; import { ServerResolve } from './resolvers/server-resolve'; import { ApplianceService } from './services/appliances.service'; +import { ProtocolHandlerService } from './services/protocol-handler.service'; import { BuiltInTemplatesConfigurationService } from './services/built-in-templates-configuration.service'; import { BuiltInTemplatesService } from './services/built-in-templates.service'; import { ComputeService } from './services/compute.service'; @@ -238,7 +239,6 @@ import { NodeService } from './services/node.service'; import { NodeConsoleService } from './services/nodeConsole.service'; import { NotificationService } from './services/notification.service'; import { PacketCaptureService } from './services/packet-capture.service'; -import { ProtocolHandlerService } from './services/protocol-handler.service'; import { PlatformService } from './services/platform.service'; import { ProjectService } from './services/project.service'; import { QemuConfigurationService } from './services/qemu-configuration.service'; diff --git a/src/app/components/project-map/log-console/log-console.component.spec.ts b/src/app/components/project-map/log-console/log-console.component.spec.ts index 1d7886c3..bc6cc8b5 100644 --- a/src/app/components/project-map/log-console/log-console.component.spec.ts +++ b/src/app/components/project-map/log-console/log-console.component.spec.ts @@ -6,6 +6,7 @@ import { MatMenuModule } from '@angular/material/menu'; import { BrowserModule } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; import { ToasterService } from '../../../services/toaster.service'; +import { ProtocolHandlerService } from '../../../services/protocol-handler.service'; import { of } from 'rxjs'; import { NodesDataSource } from '../../../cartography/datasources/nodes-datasource'; import { ProjectWebServiceHandler, WebServiceMessage } from '../../../handlers/project-web-service-handler'; @@ -38,6 +39,7 @@ describe('LogConsoleComponent', () => { let nodeConsoleService: NodeConsoleService; let mapSettingsService: MapSettingsService; let toasterService: ToasterService; + let protocolHandlerService: ProtocolHandlerService; let httpServer = new HttpServer({} as HttpClient, {} as ServerErrorHandler); @@ -52,6 +54,7 @@ describe('LogConsoleComponent', () => { { provide: HttpServer, useValue: httpServer }, NodeConsoleService, ToasterService, + ProtocolHandlerService, MapSettingsService ], declarations: [LogConsoleComponent], @@ -59,6 +62,7 @@ describe('LogConsoleComponent', () => { }).compileComponents(); toasterService = TestBed.inject(ToasterService); + protocolHandlerService = TestBed.inject(ProtocolHandlerService); mapSettingsService = TestBed.inject(MapSettingsService); nodeConsoleService = TestBed.inject(NodeConsoleService); })); diff --git a/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.spec.ts b/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.spec.ts index ebb8a644..73571515 100644 --- a/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.spec.ts +++ b/src/app/components/project-map/packet-capturing/start-capture/start-capture.component.spec.ts @@ -17,6 +17,7 @@ import { ToasterService } from '../../../../services/toaster.service'; import { MockedToasterService } from '../../../../services/toaster.service.spec'; import { MockedLinkService, MockedNodesDataSource } from '../../project-map.component.spec'; import { StartCaptureDialogComponent } from './start-capture.component'; +import { ProtocolHandlerService } from '../../../../services/protocol-handler.service'; describe('StartCaptureDialogComponent', () => { let component: StartCaptureDialogComponent; @@ -25,6 +26,8 @@ describe('StartCaptureDialogComponent', () => { let mockedToasterService = new MockedToasterService(); let mockedLinkService = new MockedLinkService(); let mockedNodesDataSource = new MockedNodesDataSource(); + let protocolHandlerService: ProtocolHandlerService; + let dialogRef = { close: jasmine.createSpy('close'), }; @@ -49,10 +52,13 @@ describe('StartCaptureDialogComponent', () => { { provide: LinkService, useValue: mockedLinkService }, { provide: NodesDataSource, useValue: mockedNodesDataSource }, { provide: PacketCaptureService }, + ProtocolHandlerService, ], declarations: [StartCaptureDialogComponent], schemas: [NO_ERRORS_SCHEMA], }).compileComponents(); + + protocolHandlerService = TestBed.inject(ProtocolHandlerService); })); beforeEach(() => { From 42599dafb5f8f9d74da5d4f122dd2d0b34f7e867 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 20:07:30 +0700 Subject: [PATCH 08/11] Auxiliary console support --- src/app/cartography/models/node.ts | 1 + .../console-device-action-browser.component.html | 8 ++++++++ .../console-device-action-browser.component.ts | 15 +++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/app/cartography/models/node.ts b/src/app/cartography/models/node.ts index 8bef9b6a..c422e428 100644 --- a/src/app/cartography/models/node.ts +++ b/src/app/cartography/models/node.ts @@ -14,6 +14,7 @@ export class Properties { headless: boolean; linked_clone: boolean; on_close: string; + aux: number; ram: number; nvram: number; usage: string; diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html index 15f3f924..6faeccf9 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.html @@ -2,3 +2,11 @@ web_asset Console + diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index c521be41..7f517e3e 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -18,14 +18,14 @@ export class ConsoleDeviceActionBrowserComponent { constructor(private toasterService: ToasterService, private nodeService: NodeService, private protocolHandlerService: ProtocolHandlerService) {} - openConsole() { + openConsole(auxiliary: boolean = false) { this.nodeService.getNode(this.server, this.node).subscribe((node: Node) => { this.node = node; - this.startConsole(); + this.startConsole(auxiliary); }); } - startConsole() { + startConsole(auxiliary: boolean) { if (this.node.status !== 'started') { this.toasterService.error('This node must be started before a console can be opened'); } else { @@ -44,7 +44,14 @@ export class ConsoleDeviceActionBrowserComponent { host = `[${host}]`; } if (this.node.console_type === 'telnet') { - uri = `gns3+telnet://${host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; + + var console_port; + if (auxiliary === true) { + console_port = this.node.properties.aux; + } else { + console_port = this.node.console; + } + uri = `gns3+telnet://${host}:${console_port}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; } else if (this.node.console_type === 'vnc') { uri = `gns3+vnc://${host}:${this.node.console}?name=${this.node.name}&project_id=${this.node.project_id}&node_id=${this.node.node_id}`; } else if (this.node.console_type.startsWith('spice')) { From a9781943d509367c4a2dd726a8248efa94d21ef8 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 14 May 2024 22:11:38 +0700 Subject: [PATCH 09/11] Check auxiliary console port is defined --- .../console-device-action-browser.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts index 7f517e3e..1f01294a 100644 --- a/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts +++ b/src/app/components/project-map/context-menu/actions/console-device-action-browser/console-device-action-browser.component.ts @@ -48,6 +48,10 @@ export class ConsoleDeviceActionBrowserComponent { var console_port; if (auxiliary === true) { console_port = this.node.properties.aux; + if (console_port === undefined) { + this.toasterService.error('Auxiliary console port is not set.'); + return; + } } else { console_port = this.node.console; } @@ -61,6 +65,7 @@ export class ConsoleDeviceActionBrowserComponent { return window.open(uri); // open an http console directly in a new window/tab } else { this.toasterService.error('Supported console types are: telnet, vnc, spice and spice+agent.'); + return; } this.protocolHandlerService.open(uri); From 5b41f9789a60b62b028a419136371e10c68756b7 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 15 May 2024 11:51:18 +0700 Subject: [PATCH 10/11] Release v2.2.47 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbab9fd8..5258c01a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gns3-web-ui", - "version": "2.2.47.dev1", + "version": "2.2.47", "author": { "name": "GNS3 Technology Inc.", "email": "developers@gns3.com" From f94d59206e5ebe93faf4aa317b0599d19e87f5cb Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 15 May 2024 16:28:14 +0700 Subject: [PATCH 11/11] Development on 2.2.48.dev1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5258c01a..e702a6f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gns3-web-ui", - "version": "2.2.47", + "version": "2.2.48.dev1", "author": { "name": "GNS3 Technology Inc.", "email": "developers@gns3.com"