mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-31 14:30:43 +00:00
Support for packet capture
This commit is contained in:
parent
cdbf2e4eb2
commit
a989a88dbb
@ -236,6 +236,7 @@ import { TracengService } from './services/traceng.service';
|
|||||||
import { TracengTemplateDetailsComponent } from './components/preferences/traceng/traceng-template-details/traceng-template-details.component';
|
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 { 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 { ChooseNameDialogComponent } from './components/projects/choose-name-dialog/choose-name-dialog.component';
|
||||||
|
import { PacketCaptureService } from './services/packet-capture.service';
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -478,7 +479,8 @@ if (environment.production) {
|
|||||||
MapSettingsService,
|
MapSettingsService,
|
||||||
InfoService,
|
InfoService,
|
||||||
ComputeService,
|
ComputeService,
|
||||||
TracengService
|
TracengService,
|
||||||
|
PacketCaptureService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -3,6 +3,7 @@ import { Server } from '../../../../../models/server';
|
|||||||
import { Link } from '../../../../../models/link';
|
import { Link } from '../../../../../models/link';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { StartCaptureDialogComponent } from '../../../packet-capturing/start-capture/start-capture.component';
|
import { StartCaptureDialogComponent } from '../../../packet-capturing/start-capture/start-capture.component';
|
||||||
|
import { Project } from '../../../../../models/project';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-start-capture-action',
|
selector: 'app-start-capture-action',
|
||||||
@ -10,6 +11,7 @@ import { StartCaptureDialogComponent } from '../../../packet-capturing/start-cap
|
|||||||
})
|
})
|
||||||
export class StartCaptureActionComponent {
|
export class StartCaptureActionComponent {
|
||||||
@Input() server: Server;
|
@Input() server: Server;
|
||||||
|
@Input() project: Project;
|
||||||
@Input() link: Link;
|
@Input() link: Link;
|
||||||
|
|
||||||
constructor(private dialog: MatDialog) {}
|
constructor(private dialog: MatDialog) {}
|
||||||
@ -21,6 +23,7 @@ export class StartCaptureActionComponent {
|
|||||||
});
|
});
|
||||||
let instance = dialogRef.componentInstance;
|
let instance = dialogRef.componentInstance;
|
||||||
instance.server = this.server;
|
instance.server = this.server;
|
||||||
|
instance.project = this.project;
|
||||||
instance.link = this.link;
|
instance.link = this.link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
formControlName="fileName"
|
formControlName="fileName"
|
||||||
matInput type="text">
|
matInput type="text">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<!-- <mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="startProgram">
|
<mat-checkbox [ngModelOptions]="{standalone: true}" [(ngModel)]="startProgram">
|
||||||
Start the capture visualization program
|
Start the capture visualization program
|
||||||
</mat-checkbox> -->
|
</mat-checkbox>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'
|
|||||||
import { ToasterService } from '../../../../services/toaster.service';
|
import { ToasterService } from '../../../../services/toaster.service';
|
||||||
import { LinkNode } from '../../../../models/link-node';
|
import { LinkNode } from '../../../../models/link-node';
|
||||||
import { NodesDataSource } from '../../../../cartography/datasources/nodes-datasource';
|
import { NodesDataSource } from '../../../../cartography/datasources/nodes-datasource';
|
||||||
|
import { PacketCaptureService } from '../../../../services/packet-capture.service';
|
||||||
|
import { Project } from '../../../../models/project';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-start-capture',
|
selector: 'app-start-capture',
|
||||||
@ -17,6 +19,7 @@ import { NodesDataSource } from '../../../../cartography/datasources/nodes-datas
|
|||||||
})
|
})
|
||||||
export class StartCaptureDialogComponent implements OnInit {
|
export class StartCaptureDialogComponent implements OnInit {
|
||||||
server: Server;
|
server: Server;
|
||||||
|
project: Project;
|
||||||
link: Link;
|
link: Link;
|
||||||
linkTypes = [];
|
linkTypes = [];
|
||||||
inputForm: FormGroup;
|
inputForm: FormGroup;
|
||||||
@ -27,7 +30,8 @@ export class StartCaptureDialogComponent implements OnInit {
|
|||||||
private linkService: LinkService,
|
private linkService: LinkService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private toasterService: ToasterService,
|
private toasterService: ToasterService,
|
||||||
private nodesDataSource: NodesDataSource
|
private nodesDataSource: NodesDataSource,
|
||||||
|
private packetCaptureService: PacketCaptureService
|
||||||
) {
|
) {
|
||||||
this.inputForm = this.formBuilder.group({
|
this.inputForm = this.formBuilder.group({
|
||||||
linkType: new FormControl('', Validators.required),
|
linkType: new FormControl('', Validators.required),
|
||||||
@ -73,6 +77,10 @@ export class StartCaptureDialogComponent implements OnInit {
|
|||||||
data_link_type: this.inputForm.get('linkType').value
|
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.linkService.startCaptureOnLink(this.server, this.link, captureSettings).subscribe(() => {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
});
|
});
|
||||||
|
17
src/app/services/packet-capture.service.ts
Normal file
17
src/app/services/packet-capture.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user