|
|
|
|
@@ -91,6 +91,15 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
this.showIntro = false;
|
|
|
|
|
this.changeDetector.detectChanges();
|
|
|
|
|
|
|
|
|
|
const svg = d3.select(this.discoveryTargetRef.nativeElement);
|
|
|
|
|
|
|
|
|
|
const _zoom = d3.zoom().on('zoom', () => {
|
|
|
|
|
const transform = d3.event.transform;
|
|
|
|
|
svg.select('g').attr('transform', 'translate(' + transform.x + ',' + transform.y + ') scale(' + transform.k + ')');
|
|
|
|
|
});
|
|
|
|
|
svg.call(_zoom);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const width = this.discoveryTargetRef.nativeElement.clientWidth;
|
|
|
|
|
const height = this.discoveryTargetRef.nativeElement.clientHeight;
|
|
|
|
|
|
|
|
|
|
@@ -106,7 +115,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
this.nodes.push(
|
|
|
|
|
{ id: '192.168.1.0/24', fx: width / 2, fy: height / 2 },
|
|
|
|
|
{ id: '192.168.1.0/24', group: 'zone', target: this.zone, fx: width / 2, fy: height / 2 },
|
|
|
|
|
// { id: '192.168.1.1' },
|
|
|
|
|
// { id: '192.168.1.2' },
|
|
|
|
|
);
|
|
|
|
|
@@ -118,64 +127,31 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
this.simulationRestart();
|
|
|
|
|
|
|
|
|
|
const zone: Zone = {
|
|
|
|
|
network: '192.168.1.0/24',
|
|
|
|
|
iface: 'enp3s0',
|
|
|
|
|
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
|
|
|
|
address: '192.168.1.101',
|
|
|
|
|
mac: '44:8a:5b:f1:f1:f3',
|
|
|
|
|
};
|
|
|
|
|
// const zone: Zone = {
|
|
|
|
|
// network: '192.168.1.0/24',
|
|
|
|
|
// iface: 'enp3s0',
|
|
|
|
|
// metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
|
|
|
|
// address: '192.168.1.101',
|
|
|
|
|
// mac: '44:8a:5b:f1:f1:f3',
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
const discoverHost: DiscoverHost = {
|
|
|
|
|
metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
|
|
|
|
firstScanRange: '192.168.1.1',
|
|
|
|
|
lastScanRange: '192.168.1.254',
|
|
|
|
|
discoveryConfig: {
|
|
|
|
|
},
|
|
|
|
|
discoverPort: {
|
|
|
|
|
firstScanRange: 1,
|
|
|
|
|
lastScanRange: 65535,
|
|
|
|
|
includeTCP: true,
|
|
|
|
|
includeUDP: true,
|
|
|
|
|
discoverService: {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.probeService.send('DiscoveryService.DiscoverHost', requesterID, zone, discoverHost);
|
|
|
|
|
|
|
|
|
|
// this.nodeSet = new vis.DataSet([
|
|
|
|
|
// {
|
|
|
|
|
// id: '192.168.1.0/24', label: 'Zone', group: 'zone',
|
|
|
|
|
// shape: 'image',
|
|
|
|
|
// image: '../../assets/Windows_logo.png',
|
|
|
|
|
// const discoverHost: DiscoverHost = {
|
|
|
|
|
// metaIPType: toMetaIPType(MetaIPTypeEnum.V4),
|
|
|
|
|
// firstScanRange: '192.168.1.1',
|
|
|
|
|
// lastScanRange: '192.168.1.254',
|
|
|
|
|
// discoveryConfig: {
|
|
|
|
|
// },
|
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
|
|
// this.edgeSet = new vis.DataSet([]);
|
|
|
|
|
|
|
|
|
|
// const options = {
|
|
|
|
|
// width: '100%',
|
|
|
|
|
// height: '100%',
|
|
|
|
|
// groups: {
|
|
|
|
|
// zone: { color: { background: 'red' }, borderWidth: 5 },
|
|
|
|
|
// host: { color: { background: 'blue' }, borderWidth: 3 },
|
|
|
|
|
// service: { color: { background: 'white' }, borderWidth: 1 },
|
|
|
|
|
// discoverPort: {
|
|
|
|
|
// firstScanRange: 1,
|
|
|
|
|
// lastScanRange: 65535,
|
|
|
|
|
// includeTCP: true,
|
|
|
|
|
// includeUDP: true,
|
|
|
|
|
// discoverService: {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// this.visNetwork = new vis.Network(this.discoveryTargetRef.nativeElement, { nodes: this.nodeSet, edges: this.edgeSet }, options);
|
|
|
|
|
// this.visNetwork.on('click', (params) => {
|
|
|
|
|
// const ids = params.nodes;
|
|
|
|
|
// const clickedNode = this.nodeSet.get(ids);
|
|
|
|
|
// if (clickedNode.length > 0) {
|
|
|
|
|
// this.displaySidebar = true;
|
|
|
|
|
// this.selectedNode = clickedNode[0];
|
|
|
|
|
// } else {
|
|
|
|
|
// this.displaySidebar = false;
|
|
|
|
|
// this.selectedNode = null;
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
this.probeService.send('DiscoveryService.DiscoverHost', requesterID, this.zone, this.discoverHost);
|
|
|
|
|
|
|
|
|
|
// this.probeService.send(
|
|
|
|
|
// 'DiscoveryService.DiscoverHost',
|
|
|
|
|
@@ -195,6 +171,11 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onTargetClick(node: Node) {
|
|
|
|
|
this.displaySidebar = true;
|
|
|
|
|
this.selectedNode = node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DiscoverHost
|
|
|
|
|
*/
|
|
|
|
|
@@ -255,7 +236,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
console.log('DiscoveredHost', host);
|
|
|
|
|
const hostId = `${host.address}`;
|
|
|
|
|
const zoneNode = this.getNode('192.168.1.0/24');
|
|
|
|
|
const hostNode = new Node(hostId);
|
|
|
|
|
const hostNode = new Node(hostId, 'host', host);
|
|
|
|
|
hostNode.x = zoneNode.x;
|
|
|
|
|
hostNode.y = zoneNode.y;
|
|
|
|
|
|
|
|
|
|
@@ -282,7 +263,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|
|
|
|
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.key}`;
|
|
|
|
|
|
|
|
|
|
const hostNode = this.getNode(hostId);
|
|
|
|
|
const serviceNode = new Node(serviceId);
|
|
|
|
|
const serviceNode = new Node(serviceId, 'service', service);
|
|
|
|
|
serviceNode.x = hostNode.x;
|
|
|
|
|
serviceNode.y = hostNode.y;
|
|
|
|
|
|
|
|
|
|
|