From 957d4aba8bf010cd471763a1a2933a2db68b640a Mon Sep 17 00:00:00 2001 From: Srinaath Ravichandran Date: Wed, 18 Mar 2020 10:55:39 -0700 Subject: [PATCH] Ngrok reporting made accurate (#2113) * Recator isUsingNgrok --- CHANGELOG.md | 2 +- packages/app/main/src/ngrokService.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49b4b55e7..cfb80165c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [client] Disable "Restart conversation from here" bubble on DL Speech bots [2107](https://github.com/microsoft/BotFramework-Emulator/pull/2107) - [client] Fixed an issue where starting a conversation with an unset custom user ID was causing the User member of the conversation to have a blank `id` field in PR [2108](https://github.com/microsoft/BotFramework-Emulator/pull/2108) - [main] Fixed an issue where the setting `Bypass Ngrok for local addresses` was continuing to use the ngrok tunnel even for local bots in PR [2111](https://github.com/microsoft/BotFramework-Emulator/pull/2111) - +- [main] Ngrok Reporting made accurate in PR [2113](https://github.com/microsoft/BotFramework-Emulator/pull/2113) ## v4.8.0 - 2019 - 03 - 12 ## Added diff --git a/packages/app/main/src/ngrokService.ts b/packages/app/main/src/ngrokService.ts index 75cb100e5..90af3fb5d 100644 --- a/packages/app/main/src/ngrokService.ts +++ b/packages/app/main/src/ngrokService.ts @@ -74,13 +74,7 @@ export class NgrokService { if (this.pendingRecycle) { await this.pendingRecycle; } - - const { bypassNgrokLocalhost, runNgrokAtStartup } = getSettings().framework; - // Use ngrok - const local = !botUrl || isLocalHostUrl(botUrl); - - const useNgrok = runNgrokAtStartup || !local || (local && !bypassNgrokLocalhost); - if (useNgrok) { + if (this.isUsingNgrok(botUrl)) { if (!this.ngrok.running()) { await this.startup(); } @@ -237,7 +231,7 @@ export class NgrokService { ); } else if (!this.ngrokPath) { this.reportNotConfigured(conversationId); - } else if (this.ngrok.running()) { + } else if (this.isUsingNgrok(botUrl)) { this.reportRunning(conversationId); } else { emulatorApplication.mainWindow.logService.logToChat( @@ -312,4 +306,10 @@ export class NgrokService { } this.localhost = hostname; } + + private isUsingNgrok(botUrl: string) { + const { bypassNgrokLocalhost, runNgrokAtStartup } = getSettings().framework; + const local = !botUrl || isLocalHostUrl(botUrl); + return runNgrokAtStartup || !local || (local && !bypassNgrokLocalhost); + } }