lan address added

This commit is contained in:
Drew Ansbacher
2021-10-17 18:33:46 -06:00
committed by Aiden McClelland
parent 55bf7c71da
commit cc2e937216
7 changed files with 35 additions and 12 deletions

View File

@@ -91,7 +91,7 @@ export class EmbassyPage {
this.stateService.embassyPassword = ret.data.password this.stateService.embassyPassword = ret.data.password
try { try {
this.stateService.torAddress = (await this.stateService.setupEmbassy()).torAddress await this.stateService.setupEmbassy()
} catch (e) { } catch (e) {
this.errorToastService.present(`${e.message}: ${e.details}`) this.errorToastService.present(`${e.message}: ${e.details}`)
console.error(e.message) console.error(e.message)

View File

@@ -20,7 +20,7 @@
<p>{{ stateService.torAddress }}</p> <p>{{ stateService.torAddress }}</p>
</ion-label> </ion-label>
<ion-buttons> <ion-buttons>
<ion-button fill="clear" (click)="copy()"> <ion-button fill="clear" (click)="copy(stateService.torAddress)">
<ion-icon size="small" slot="icon-only" name="copy-outline"></ion-icon> <ion-icon size="small" slot="icon-only" name="copy-outline"></ion-icon>
</ion-button> </ion-button>
</ion-buttons> </ion-buttons>
@@ -41,7 +41,7 @@
<div <div
[ngStyle]="{ [ngStyle]="{
'overflow' : 'hidden', 'overflow' : 'hidden',
'max-height': lanInstructionsOpen ? '355px' : '0px', 'max-height': lanInstructionsOpen ? '455px' : '0px',
'transition': 'max-height 0.4s ease-out' 'transition': 'max-height 0.4s ease-out'
}" }"
> >
@@ -65,6 +65,19 @@
<p>Download and trust your Embassy's Root Cert</p> <p>Download and trust your Embassy's Root Cert</p>
</ion-label> </ion-label>
</ion-item> </ion-item>
<p style="padding-top: 10px;" class="addr-label">LAN Address:</p>
<ion-item style="--border-radius: 8px !important;" color="medium">
<ion-label>
<p>{{ stateService.lanAddress }}</p>
</ion-label>
<ion-buttons>
<ion-button fill="clear" (click)="copy(stateService.lanAddress)">
<ion-icon size="small" slot="icon-only" name="copy-outline"></ion-icon>
</ion-button>
</ion-buttons>
</ion-item>
</ion-item-group> </ion-item-group>
</div> </div>
</ion-card-content> </ion-card-content>

View File

@@ -16,9 +16,9 @@ export class SuccessPage {
window = window window = window
lanInstructionsOpen = false lanInstructionsOpen = false
async copy (): Promise<void> { async copy (address: string): Promise<void> {
let message = '' let message = ''
await this.copyToClipboard(this.stateService.torAddress) await this.copyToClipboard(address)
.then(success => message = success ? 'copied to clipboard!' : 'failed to copy') .then(success => message = success ? 'copied to clipboard!' : 'failed to copy')
const toast = await this.toastCtrl.create({ const toast = await this.toastCtrl.create({

View File

@@ -8,7 +8,7 @@ export abstract class ApiService {
// encrypted // encrypted
abstract verifyProductKey (): Promise<void> // echo - throws error if invalid abstract verifyProductKey (): Promise<void> // echo - throws error if invalid
abstract verify03XPassword (logicalname: string, password: string): Promise<boolean> // setup.recovery.test-password abstract verify03XPassword (logicalname: string, password: string): Promise<boolean> // setup.recovery.test-password
abstract setupEmbassy (setupInfo: SetupEmbassyReq): Promise<string> // setup.execute abstract setupEmbassy (setupInfo: SetupEmbassyReq): Promise<SetupEmbassyRes> // setup.execute
} }
export interface GetStatusRes { export interface GetStatusRes {
@@ -23,6 +23,11 @@ export interface SetupEmbassyReq {
'recovery-password'?: string 'recovery-password'?: string
} }
export interface SetupEmbassyRes {
'tor-address': string
'lan-address': string
}
export interface DiskInfo { export interface DiskInfo {
logicalname: string, logicalname: string,
vendor: string | null, vendor: string | null,

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { ApiService, DiskInfo, GetStatusRes, RecoveryStatusRes, SetupEmbassyReq } from './api.service' import { ApiService, DiskInfo, GetStatusRes, RecoveryStatusRes, SetupEmbassyReq, SetupEmbassyRes } from './api.service'
import { HttpService } from './http.service' import { HttpService } from './http.service'
@Injectable({ @Injectable({
@@ -46,7 +46,7 @@ export class LiveApiService extends ApiService {
async verifyProductKey () { async verifyProductKey () {
return this.http.rpcRequest<void>({ return this.http.rpcRequest<void>({
method: 'echo', method: 'echo',
params: { "message": "hello" }, params: { 'message': 'hello' },
}) })
} }
@@ -58,7 +58,7 @@ export class LiveApiService extends ApiService {
} }
async setupEmbassy (setupInfo: SetupEmbassyReq) { async setupEmbassy (setupInfo: SetupEmbassyReq) {
return this.http.rpcRequest<string>({ return this.http.rpcRequest<SetupEmbassyRes>({
method: 'setup.execute', method: 'setup.execute',
params: setupInfo as any, params: setupInfo as any,
}) })

View File

@@ -126,7 +126,10 @@ export class MockApiService extends ApiService {
async setupEmbassy (setupInfo: SetupEmbassyReq) { async setupEmbassy (setupInfo: SetupEmbassyReq) {
await pauseFor(3000) await pauseFor(3000)
return 'asdfasdfasdf.onion' return {
'tor-address': 'asdfasdfasdf.onion',
'lan-address': 'embassy-dfasdf.local',
}
} }
async getRecoveryDrives () { async getRecoveryDrives () {

View File

@@ -21,6 +21,7 @@ export class StateService {
dataProgSubject = new BehaviorSubject(this.dataProgress) dataProgSubject = new BehaviorSubject(this.dataProgress)
torAddress: string torAddress: string
lanAddress: string
constructor ( constructor (
private readonly apiService: ApiService, private readonly apiService: ApiService,
@@ -56,14 +57,15 @@ export class StateService {
this.pollDataTransferProgress(callback) this.pollDataTransferProgress(callback)
} }
async setupEmbassy () : Promise<{ torAddress: string }> { async setupEmbassy () : Promise<void> {
const ret = await this.apiService.setupEmbassy({ const ret = await this.apiService.setupEmbassy({
'embassy-logicalname': this.storageDrive.logicalname, 'embassy-logicalname': this.storageDrive.logicalname,
'embassy-password': this.embassyPassword, 'embassy-password': this.embassyPassword,
'recovery-drive': this.recoveryDrive, 'recovery-drive': this.recoveryDrive,
'recovery-password': this.recoveryPassword, 'recovery-password': this.recoveryPassword,
}) })
return { torAddress: ret } this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address']
} }
} }