account for LAN failure

This commit is contained in:
Matt Hill
2021-07-12 12:09:00 -06:00
committed by Aiden McClelland
parent aa786bc845
commit aa976e362d
2 changed files with 18 additions and 10 deletions

View File

@@ -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 <ion-spinner name="dots"></ion-spinner>')
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)

View File

@@ -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',
}