Support for packet capture

This commit is contained in:
Piotr Pekala 2019-09-24 02:10:03 -07:00
parent cdbf2e4eb2
commit a989a88dbb
5 changed files with 34 additions and 4 deletions

View File

@ -236,6 +236,7 @@ import { TracengService } from './services/traceng.service';
import { TracengTemplateDetailsComponent } from './components/preferences/traceng/traceng-template-details/traceng-template-details.component';
import { QemuImageCreatorComponent } from './components/project-map/node-editors/configurator/qemu/qemu-image-creator/qemu-image-creator.component';
import { ChooseNameDialogComponent } from './components/projects/choose-name-dialog/choose-name-dialog.component';
import { PacketCaptureService } from './services/packet-capture.service';
if (environment.production) {
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
@ -478,7 +479,8 @@ if (environment.production) {
MapSettingsService,
InfoService,
ComputeService,
TracengService
TracengService,
PacketCaptureService
],
entryComponents: [
AddServerDialogComponent,

View File

@ -3,6 +3,7 @@ import { Server } from '../../../../../models/server';
import { Link } from '../../../../../models/link';
import { MatDialog } from '@angular/material';
import { StartCaptureDialogComponent } from '../../../packet-capturing/start-capture/start-capture.component';
import { Project } from '../../../../../models/project';
@Component({
selector: 'app-start-capture-action',
@ -10,6 +11,7 @@ import { StartCaptureDialogComponent } from '../../../packet-capturing/start-cap
})
export class StartCaptureActionComponent {
@Input() server: Server;
@Input() project: Project;
@Input() link: Link;
constructor(private dialog: MatDialog) {}
@ -21,6 +23,7 @@ export class StartCaptureActionComponent {
});
let instance = dialogRef.componentInstance;
instance.server = this.server;
instance.project = this.project;
instance.link = this.link;
}
}

View File

@ -18,9 +18,9 @@
formControlName="fileName"
matInput type="text">
</mat-form-field>
<!-- <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="startProgram">
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="startProgram">
Start the capture visualization program
</mat-checkbox> -->
</mat-checkbox>
</form>
</div>

View File

@ -9,6 +9,8 @@ import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'
import { ToasterService } from '../../../../services/toaster.service';
import { LinkNode } from '../../../../models/link-node';
import { NodesDataSource } from '../../../../cartography/datasources/nodes-datasource';
import { PacketCaptureService } from '../../../../services/packet-capture.service';
import { Project } from '../../../../models/project';
@Component({
selector: 'app-start-capture',
@ -17,6 +19,7 @@ import { NodesDataSource } from '../../../../cartography/datasources/nodes-datas
})
export class StartCaptureDialogComponent implements OnInit {
server: Server;
project: Project;
link: Link;
linkTypes = [];
inputForm: FormGroup;
@ -27,7 +30,8 @@ export class StartCaptureDialogComponent implements OnInit {
private linkService: LinkService,
private formBuilder: FormBuilder,
private toasterService: ToasterService,
private nodesDataSource: NodesDataSource
private nodesDataSource: NodesDataSource,
private packetCaptureService: PacketCaptureService
) {
this.inputForm = this.formBuilder.group({
linkType: new FormControl('', Validators.required),
@ -73,6 +77,10 @@ export class StartCaptureDialogComponent implements OnInit {
data_link_type: this.inputForm.get('linkType').value
};
if (this.startProgram) {
this.packetCaptureService.startCapture(this.server, this.project, this.link, captureSettings.capture_file_name);
}
this.linkService.startCaptureOnLink(this.server, this.link, captureSettings).subscribe(() => {
this.dialogRef.close();
});

View File

@ -0,0 +1,17 @@
import { Injectable } from "@angular/core";
import { HttpServer } from './http-server.service';
import { Server } from '../models/server';
import { VpcsTemplate } from '../models/templates/vpcs-template';
import { Observable } from 'rxjs';
import { HttpHeaders } from '@angular/common/http';
import { Project } from '../models/project';
import { Link } from '../models/link';
@Injectable()
export class PacketCaptureService {
constructor(private httpServer: HttpServer) {}
startCapture(server: Server, project: Project, link: Link, name: string) {
location.assign(`gns3+pcap://${server.host}:${server.port}?project_id=${project.project_id}&link_id=${link.link_id}&name=${name}`);
}
}