From a66411663dca8e0c3a9e3fc231e7041c4fb062c3 Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 7 Mar 2018 14:55:14 +0900 Subject: [PATCH] added discovery --- .../sensor-setting-page.component.ts | 2 +- .../sensor-setting-page.module.ts | 4 ++- .../discovery/model/DiscoveryStartInfo.ts | 11 +++++++ src/packages/discovery/model/Host.ts | 16 ++++++++++ src/packages/discovery/model/Port.ts | 15 +++++++++ src/packages/discovery/model/PortType.ts | 10 ++++++ src/packages/discovery/model/Service.ts | 14 +++++++++ src/packages/discovery/model/Zone.ts | 14 +++++++++ .../service/discovery.service.spec.ts | 0 .../discovery/service/discovery.service.ts | 31 +++++++++++++++++++ src/packages/discovery/service/index.ts | 0 11 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 src/packages/discovery/model/DiscoveryStartInfo.ts create mode 100644 src/packages/discovery/model/Host.ts create mode 100644 src/packages/discovery/model/Port.ts create mode 100644 src/packages/discovery/model/PortType.ts create mode 100644 src/packages/discovery/model/Service.ts create mode 100644 src/packages/discovery/model/Zone.ts create mode 100644 src/packages/discovery/service/discovery.service.spec.ts create mode 100644 src/packages/discovery/service/discovery.service.ts create mode 100644 src/packages/discovery/service/index.ts diff --git a/src/app/pages/sensor-setting/sensor-setting-page.component.ts b/src/app/pages/sensor-setting/sensor-setting-page.component.ts index a86316b..994fced 100644 --- a/src/app/pages/sensor-setting/sensor-setting-page.component.ts +++ b/src/app/pages/sensor-setting/sensor-setting-page.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import {MatDialog} from '@angular/material'; -import { DiscoverySettingComponent } from 'packages/sensor/component/setting/setting.component'; +import { SettingComponent as DiscoverySettingComponent } from 'packages/discovery/component/setting/setting.component'; @Component({ diff --git a/src/app/pages/sensor-setting/sensor-setting-page.module.ts b/src/app/pages/sensor-setting/sensor-setting-page.module.ts index d273ede..b8d5cfd 100644 --- a/src/app/pages/sensor-setting/sensor-setting-page.module.ts +++ b/src/app/pages/sensor-setting/sensor-setting-page.module.ts @@ -7,7 +7,8 @@ import { MaterialModule } from 'app/commons/ui/material/material.module'; import { FormsModule } from '@angular/forms'; -import { DiscoverySettingComponent } from 'packages/sensor/component/setting/setting.component'; +import { SettingComponent as DiscoverySettingComponent } from 'packages/discovery/component/setting/setting.component'; +import { DiscoveryModule } from 'packages/discovery/discovery.module'; @@ -18,6 +19,7 @@ import { DiscoverySettingComponent } from 'packages/sensor/component/setting/set SensorSettingPageRoutingModule, SensorModule, FormsModule, + DiscoveryModule ], entryComponents: [ DiscoverySettingComponent diff --git a/src/packages/discovery/model/DiscoveryStartInfo.ts b/src/packages/discovery/model/DiscoveryStartInfo.ts new file mode 100644 index 0000000..3d7b6de --- /dev/null +++ b/src/packages/discovery/model/DiscoveryStartInfo.ts @@ -0,0 +1,11 @@ + +export interface DiscoveryStartInfo { + startIp: string; + endIP: string; + excludeIp: string; + startPort: string; + endPort: string; + services: Array; +} + +// export default DiscoveryStartInfo; diff --git a/src/packages/discovery/model/Host.ts b/src/packages/discovery/model/Host.ts new file mode 100644 index 0000000..3783f60 --- /dev/null +++ b/src/packages/discovery/model/Host.ts @@ -0,0 +1,16 @@ +import Port from './Port'; +import Zone from './Zone'; + +interface Host { + id?: number; + ip: number; + mac: number; + createDate?: Date; + updateDate: Date; + os: string; + target: boolean; + ports?: Port[]; + zone?: Zone; +} + +export default Host; diff --git a/src/packages/discovery/model/Port.ts b/src/packages/discovery/model/Port.ts new file mode 100644 index 0000000..8302d4d --- /dev/null +++ b/src/packages/discovery/model/Port.ts @@ -0,0 +1,15 @@ +import Host from './Host'; +import Service from './Service'; +import PortType from './PortType'; + +interface Port { + id?: number; + host: Host; + portType: PortType; + portNumber: number; + services?: Service[]; + createDate?: Date; + updateDate: Date; +} + +export default Port; diff --git a/src/packages/discovery/model/PortType.ts b/src/packages/discovery/model/PortType.ts new file mode 100644 index 0000000..26c1130 --- /dev/null +++ b/src/packages/discovery/model/PortType.ts @@ -0,0 +1,10 @@ + +// enum PortType { +// TCP = 1, +// UDP = 2, +// TLS = 3, +// } + +type PortType = 'TCP' | 'UDP' | 'TLS'; + +export default PortType; diff --git a/src/packages/discovery/model/Service.ts b/src/packages/discovery/model/Service.ts new file mode 100644 index 0000000..2297bc4 --- /dev/null +++ b/src/packages/discovery/model/Service.ts @@ -0,0 +1,14 @@ +import Port from './Port'; +import PortType from './PortType'; + +interface Service { + id: number; + port: Port; + portType: PortType; + serviceName: string; + createDate: Date; + updateDate: Date; + target: boolean; +} + +export default Service; diff --git a/src/packages/discovery/model/Zone.ts b/src/packages/discovery/model/Zone.ts new file mode 100644 index 0000000..c60435b --- /dev/null +++ b/src/packages/discovery/model/Zone.ts @@ -0,0 +1,14 @@ +import Host from './Host'; + +export interface Zone { + id?: number; + network?: string; + ip?: string; + iface?: string; + mac?: string; + firstScanRange?: number; + lastScanRange?: number; + hosts?: Host[]; +} + +export default Zone; diff --git a/src/packages/discovery/service/discovery.service.spec.ts b/src/packages/discovery/service/discovery.service.spec.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/packages/discovery/service/discovery.service.ts b/src/packages/discovery/service/discovery.service.ts new file mode 100644 index 0000000..a008abd --- /dev/null +++ b/src/packages/discovery/service/discovery.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; + +import 'rxjs/add/operator/map'; + +import { RESTService } from 'packages/commons/service/rest.service'; + +import { DiscoveryStartInfo } from '../model/DiscoveryStartInfo'; + +@Injectable() +export class DiscoveryService { + + public constructor( + private restService: RESTService, + ) { + + } + + public start(dsInfo: DiscoveryStartInfo): Observable { + // const body = { + // signinId: email, + // signinPw: password, + // }; + + return this.restService.post('/discovery/start', dsInfo); + } + +// public signup(member: DiscoveryStartInfo): Observable { +// return this.restService.post('/account/signup', member); +// } +} diff --git a/src/packages/discovery/service/index.ts b/src/packages/discovery/service/index.ts new file mode 100644 index 0000000..e69de29