From aa976e362de8497e988e83a62ade984b8c3c4b03 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 12 Jul 2021 12:09:00 -0600 Subject: [PATCH] account for LAN failure --- ui/src/app/app.component.ts | 12 ++++++++---- ui/src/app/services/connection.service.ts | 16 ++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index e089aaeb5..239b99f6b 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -127,21 +127,25 @@ export class AppComponent { let link: string switch (connectionFailure) { case ConnectionFailure.Network: - message = 'Your phone or computer has no network connection.' + message = 'Phone or computer has no network connection.' break case ConnectionFailure.Diagnosing: message = new IonicSafeString('Running network diagnostics ') break case ConnectionFailure.Embassy: - message = 'Your Embassy appears to be offline.' + message = 'Embassy appears to be offline.' link = 'https://docs.start9.com/support/FAQ/setup-faq.html#embassy-offline' break case ConnectionFailure.Tor: - message = 'Your phone or computer is currently unable to connect over Tor.' + message = 'Browser unable to connect over Tor.' link = 'https://docs.start9.com/support/FAQ/setup-faq.html#tor-failure' break case ConnectionFailure.Internet: - message = 'Your phone or computer is unable to connect to the Internet.' + message = 'Phone or computer has no Internet.' + break + case ConnectionFailure.Lan: + message = 'Embassy not found on Local Area Network.' + link = 'https://docs.start9.com/support/FAQ/setup-faq.html#lan-failure' break } await this.presentToastOffline(message, link) diff --git a/ui/src/app/services/connection.service.ts b/ui/src/app/services/connection.service.ts index 4d5bbdf05..2eb225491 100644 --- a/ui/src/app/services/connection.service.ts +++ b/ui/src/app/services/connection.service.ts @@ -3,6 +3,7 @@ import { BehaviorSubject, combineLatest, fromEvent, merge, Subscription } from ' import { ConnectionStatus, PatchDbModel } from './patch-db/patch-db.service' import { HttpService, Method } from './http.service' import { distinctUntilChanged } from 'rxjs/operators' +import { ConfigService } from './config.service' @Injectable({ providedIn: 'root', @@ -14,6 +15,7 @@ export class ConnectionService { constructor ( private readonly httpService: HttpService, + private readonly configService: ConfigService, private readonly patch: PatchDbModel, ) { } @@ -30,26 +32,27 @@ export class ConnectionService { combineLatest([this.networkState$.pipe(distinctUntilChanged()), this.patch.watchConnection$().pipe(distinctUntilChanged())]) .subscribe(async ([network, connectionStatus]) => { - console.log('CONNECTION STATUS', connectionStatus) const addrs = this.patch.data['server-info']?.['connection-addresses'] if (connectionStatus !== ConnectionStatus.Disconnected) { this.connectionFailure$.next(ConnectionFailure.None) } else if (!network) { this.connectionFailure$.next(ConnectionFailure.Network) - } else { - console.log('diagnosing') + } else if (!this.configService.isTor()) { + this.connectionFailure$.next(ConnectionFailure.Lan) + } { + // diagnosing this.connectionFailure$.next(ConnectionFailure.Diagnosing) const torSuccess = await this.testAddrs(addrs?.tor || []) if (torSuccess) { - console.log('TOR SUCCESS, EMBASSY IS PROBLEM') + // TOR SUCCESS, EMBASSY IS PROBLEM this.connectionFailure$.next(ConnectionFailure.Embassy) } else { const clearnetSuccess = await this.testAddrs(addrs?.clearnet || []) if (clearnetSuccess) { - console.log('CLEARNET SUCCESS, TOR IS PROBLEM') + // CLEARNET SUCCESS, TOR IS PROBLEM this.connectionFailure$.next(ConnectionFailure.Tor) } else { - console.log('INTERNET IS PROBLEM') + // INTERNET IS PROBLEM this.connectionFailure$.next(ConnectionFailure.Internet) } } @@ -89,5 +92,6 @@ export enum ConnectionFailure { Network = 'network', Embassy = 'embassy', Tor = 'tor', + Lan = 'lan', Internet = 'internet', }