Working with encryption!

This commit is contained in:
Isaac Grynsztein
2018-01-16 11:18:41 -05:00
parent 162425b702
commit 917235189a
8 changed files with 77 additions and 60 deletions

View File

@@ -23,20 +23,39 @@ export class AppComponent {
constructor(private postsService: PostsService) {
this.audioOnly = true;
// starts handshake
this.doHandshake();
this.postsService.loadNavItems().subscribe(result => {
var backendUrl = result.YoutubeDLMaterial.Host.backendurl;
this.postsService.path = backendUrl;
this.postsService.startPath = backendUrl;
this.postsService.startPathSSL = backendUrl;
});
}
urlForm = new FormControl('', [Validators.required]);
doHandshake() {
this.postsService.startHandshake().subscribe(url => {
this.postsService.path = "http://" + url;
doHandshake(url: string) {
this.postsService.startHandshake(url).subscribe(theurl => {
this.postsService.path = theurl;
this.postsService.handShakeComplete = true;
console.log("Handshake complete!");
},
error => {
console.log("Initial handshake failed, make sure port 17442 is open!");
console.log("Initial handshake failed on http.");
this.doHandshakeSSL(url);
});
}
doHandshakeSSL(url: string) {
this.postsService.startHandshakeSSL(url).subscribe(theurl => {
this.postsService.path = theurl;
this.postsService.handShakeComplete = true;
console.log("Handshake complete!");
},
error => {
console.log("Initial handshake failed on https too! Make sure port 17442 is open.");
this.postsService.handShakeComplete = false;
});
}
@@ -119,3 +138,4 @@ export class AppComponent {
return re.test(str);
}
}

View File

@@ -3,8 +3,6 @@ import { NgModule } from '@angular/core';
import {MatNativeDateModule, MatRadioModule, MatInputModule, MatButtonModule, MatSidenavModule, MatIconModule, MatListModule,
MatSnackBarModule, MatCardModule, MatSelectModule, MatToolbarModule, MatCheckboxModule,
MatProgressBarModule } from '@angular/material';
import { NgConfigureModule, ConfigureOptions } from 'ng4-configure/ng4-configure';
import { MyOptions } from './configuration_options.component';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { AppComponent } from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

View File

@@ -1,7 +0,0 @@
import { ConfigureOptions } from 'ng4-configure/ng4-configure';
export class MyOptions extends ConfigureOptions {
ConfigurationURL: string = 'assets/config.json';
AppVersion: string = '0.0.0';
BustCache: boolean = false
}

View File

@@ -12,15 +12,22 @@ export class PostsService {
audioFolder: string = "";
videoFolder: string = "";
startPath: string = "http://localhost:17442/";
startPathSSL: string = "https://localhost:17442/"
handShakeComplete: boolean = false;
constructor(private http: Http){
console.log('PostsService Initialized...');
}
startHandshake(): Observable<string>
startHandshake(url: string): Observable<string>
{
return this.http.get(this.startPath + "url")
return this.http.get(url + "geturl")
.map(res => res.json());
}
startHandshakeSSL(url: string): Observable<string>
{
return this.http.get(url + "geturl")
.map(res => res.json());
}
@@ -57,6 +64,14 @@ export class PostsService {
return this.http.post(this.path + "mp4fileexists",{name: name})
.map(res => res.json());
}
loadNavItems() {
return this.http.get("../../backend/config/default.json")
.map(res => res.json());
//This is optional, you can remove the last line
// if you don't want to log loaded json in
// console.
}
}