From d8ffaa8d84094b5ac6a996ef957832ccf6ceed82 Mon Sep 17 00:00:00 2001 From: crusader Date: Sat, 28 Apr 2018 01:29:54 +0900 Subject: [PATCH] ing --- .../component/setting/setting.component.ts | 58 +++++++++++-------- src/packages/discovery/model/DiscoverHost.ts | 10 ++++ .../{DiscoveryPort.ts => DiscoverPort.ts} | 6 +- .../discovery/model/DiscoverService.ts | 3 + src/packages/discovery/model/DiscoverZone.ts | 7 +++ src/packages/discovery/model/DiscoveryHost.ts | 10 ---- .../discovery/model/DiscoveryService.ts | 3 - src/packages/discovery/model/DiscoveryZone.ts | 7 --- src/packages/discovery/model/Host.ts | 3 +- src/packages/discovery/model/Zone.ts | 3 +- src/packages/discovery/model/index.ts | 8 +-- .../discovery/service/discovery.service.ts | 24 ++++---- .../service/target-discovery.service.ts | 8 +-- .../store/discover/discover.action.ts | 16 ++--- .../store/discover/discover.effect.ts | 8 +-- .../store/discover/discover.reducer.ts | 16 ++--- 16 files changed, 102 insertions(+), 88 deletions(-) create mode 100644 src/packages/discovery/model/DiscoverHost.ts rename src/packages/discovery/model/{DiscoveryPort.ts => DiscoverPort.ts} (50%) create mode 100644 src/packages/discovery/model/DiscoverService.ts create mode 100644 src/packages/discovery/model/DiscoverZone.ts delete mode 100644 src/packages/discovery/model/DiscoveryHost.ts delete mode 100644 src/packages/discovery/model/DiscoveryService.ts delete mode 100644 src/packages/discovery/model/DiscoveryZone.ts diff --git a/src/packages/discovery/component/setting/setting.component.ts b/src/packages/discovery/component/setting/setting.component.ts index b5d5e4a..f1d5273 100644 --- a/src/packages/discovery/component/setting/setting.component.ts +++ b/src/packages/discovery/component/setting/setting.component.ts @@ -3,10 +3,10 @@ import { Store, select } from '@ngrx/store'; import { RPCClientError } from '@loafer/ng-rpc/protocol'; import { DiscoveryStartInfo, - DiscoveryZone, + DiscoverZone, Zone, - DiscoveryPort, - DiscoveryService + DiscoverPort, + DiscoverService } from '../../model'; import * as CIDR from 'ip-cidr'; import * as DiscoveredStore from '../../store/setting'; @@ -65,23 +65,35 @@ export class SettingComponent implements OnInit, AfterContentInit { includeServices = []; serviceItems = [ - { name: 'SSH' }, - { name: 'PostgreSQL' }, + { name: 'ACTIVEDIRECTORY' }, + { name: 'CASSANDRA' }, + { name: 'DHCP' }, { name: 'DNS' }, - { name: 'WMI'}, - { name: 'SMB' }, - { name: 'ActiveDirectory' }, - { name: 'Cassandra' }, { name: 'FTP' }, { name: 'HTTP' }, { name: 'IMAP' }, { name: 'LDAP' }, - { name: 'MongoDB' }, - { name: 'MySQL' }, - { name: 'NBSS' }, + { name: 'MONGODB' }, + { name: 'MSSQL' }, + { name: 'MYSQL' }, + { name: 'NETBIOS' }, + { name: 'ORACLE' }, + { name: 'POP' }, + { name: 'POSTGRESQL' }, + { name: 'REDIS' }, + { name: 'RMI' }, + { name: 'SMB' }, + { name: 'SMTP' }, + { name: 'SNMP' }, + { name: 'SSH' }, + { name: 'TELNET' }, + { name: 'WMI' }, + { name: 'UNKNOWN' }, + { name: 'SSH' }, + { name: 'WMI' }, + { name: 'SNMP' }, ]; - treeNodes = []; selectedNodes = []; zones: Map = null; @@ -256,41 +268,41 @@ export class SettingComponent implements OnInit, AfterContentInit { console.log(this.startPort); console.log(this.endPort); - let discoveryPort: DiscoveryPort = null; - let discoveryService: DiscoveryService = null; + let discoverPort: DiscoverPort = null; + let discoverService: DiscoverService = null; if (this.serviceChecked.length > 0) { const services = new Array(); for (const service of this.includeServices) { services.push(service.name); } - discoveryService = { + discoverService = { includeServices: services, }; } if (this.portChecked.length > 0) { - discoveryPort = { + discoverPort = { firstScanRange: this.startPort, lastScanRange: this.endPort, includeTCP: this.tcpChecked, includeUDP: this.udpChecked, excludePorts: null, - discoveryService: discoveryService + discoverService: discoverService }; } - const discoveryZone: DiscoveryZone = { - discoveryHost: { + const discoverZone: DiscoverZone = { + discoverHost: { firstScanRange: this.startIP, lastScanRange: this.endIP, - discoveryPort: discoveryPort, + discoverPort: discoverPort, }, }; - console.log(discoveryZone); + console.log(discoverZone); // console.log('start discovery - ' + this.probe.probeKey); this.discoverstore.dispatch(new DiscoverStore.DiscoverZone( - { probeID: this.probe.probeKey, discoveryZone: discoveryZone })); + { probeID: this.probe.probeKey, discoverZone: discoverZone })); this.started = true; } diff --git a/src/packages/discovery/model/DiscoverHost.ts b/src/packages/discovery/model/DiscoverHost.ts new file mode 100644 index 0000000..cf39668 --- /dev/null +++ b/src/packages/discovery/model/DiscoverHost.ts @@ -0,0 +1,10 @@ +import { DiscoverPort } from './DiscoverPort'; + +export interface DiscoverHost { + firstScanRange?: string; + lastScanRange?: string; + excludeHosts?: string[]; + includeHosts?: string[]; + + discoverPort?: DiscoverPort; +} diff --git a/src/packages/discovery/model/DiscoveryPort.ts b/src/packages/discovery/model/DiscoverPort.ts similarity index 50% rename from src/packages/discovery/model/DiscoveryPort.ts rename to src/packages/discovery/model/DiscoverPort.ts index 90f5e79..6031a16 100644 --- a/src/packages/discovery/model/DiscoveryPort.ts +++ b/src/packages/discovery/model/DiscoverPort.ts @@ -1,11 +1,11 @@ -import { DiscoveryService } from './DiscoveryService'; +import { DiscoverService } from './DiscoverService'; -export interface DiscoveryPort { +export interface DiscoverPort { firstScanRange: number; lastScanRange: number; excludePorts: number[]; includeTCP: boolean; includeUDP: boolean; - discoveryService?: DiscoveryService; + discoverService?: DiscoverService; } diff --git a/src/packages/discovery/model/DiscoverService.ts b/src/packages/discovery/model/DiscoverService.ts new file mode 100644 index 0000000..9145fa0 --- /dev/null +++ b/src/packages/discovery/model/DiscoverService.ts @@ -0,0 +1,3 @@ +export interface DiscoverService { + includeServices: string[]; +} diff --git a/src/packages/discovery/model/DiscoverZone.ts b/src/packages/discovery/model/DiscoverZone.ts new file mode 100644 index 0000000..33c5e6f --- /dev/null +++ b/src/packages/discovery/model/DiscoverZone.ts @@ -0,0 +1,7 @@ +import { DiscoverHost } from './DiscoverHost'; + +export interface DiscoverZone { + excludePatterns?: string[]; + + discoverHost?: DiscoverHost; +} diff --git a/src/packages/discovery/model/DiscoveryHost.ts b/src/packages/discovery/model/DiscoveryHost.ts deleted file mode 100644 index a1dc3e4..0000000 --- a/src/packages/discovery/model/DiscoveryHost.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { DiscoveryPort } from './DiscoveryPort'; - -export interface DiscoveryHost { - firstScanRange?: string; - lastScanRange?: string; - excludeHosts?: string[]; - includeHosts?: string[]; - - discoveryPort?: DiscoveryPort; -} diff --git a/src/packages/discovery/model/DiscoveryService.ts b/src/packages/discovery/model/DiscoveryService.ts deleted file mode 100644 index 96ffe70..0000000 --- a/src/packages/discovery/model/DiscoveryService.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface DiscoveryService { - includeServices: string[]; -} diff --git a/src/packages/discovery/model/DiscoveryZone.ts b/src/packages/discovery/model/DiscoveryZone.ts deleted file mode 100644 index 7a17f6a..0000000 --- a/src/packages/discovery/model/DiscoveryZone.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { DiscoveryHost } from './DiscoveryHost'; - -export interface DiscoveryZone { - excludePatterns?: string[]; - - discoveryHost?: DiscoveryHost; -} diff --git a/src/packages/discovery/model/Host.ts b/src/packages/discovery/model/Host.ts index 15f72df..76f2492 100644 --- a/src/packages/discovery/model/Host.ts +++ b/src/packages/discovery/model/Host.ts @@ -3,7 +3,8 @@ import { Port } from './Port'; export interface Host { id?: number; - ip: string; + ip4?: string; + ip6?: string; mac: number; os: string; discoveredDate?: Date; diff --git a/src/packages/discovery/model/Zone.ts b/src/packages/discovery/model/Zone.ts index 6eaa24b..edf7451 100644 --- a/src/packages/discovery/model/Zone.ts +++ b/src/packages/discovery/model/Zone.ts @@ -3,7 +3,8 @@ import { Host } from './Host'; export interface Zone { id?: number; network?: string; - ip?: string; + ip4?: string; + ip6?: string; iface?: string; mac?: string; discoveredDate?: Date; diff --git a/src/packages/discovery/model/index.ts b/src/packages/discovery/model/index.ts index c2583d5..076d52a 100644 --- a/src/packages/discovery/model/index.ts +++ b/src/packages/discovery/model/index.ts @@ -1,7 +1,7 @@ -export * from './DiscoveryHost'; -export * from './DiscoveryPort'; -export * from './DiscoveryService'; -export * from './DiscoveryZone'; +export * from './DiscoverHost'; +export * from './DiscoverPort'; +export * from './DiscoverService'; +export * from './DiscoverZone'; export * from './DiscoveryStartInfo'; export * from './Host'; export * from './Port'; diff --git a/src/packages/discovery/service/discovery.service.ts b/src/packages/discovery/service/discovery.service.ts index 26c1cd8..8a745b7 100644 --- a/src/packages/discovery/service/discovery.service.ts +++ b/src/packages/discovery/service/discovery.service.ts @@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable'; import { RPCService } from '@loafer/ng-rpc/service'; import { DiscoveryStartInfo, - DiscoveryZone, - DiscoveryHost, - DiscoveryPort, - DiscoveryService as M_DiscoveryService, + DiscoverZone as MDDiscoverZone, + DiscoverHost as MDDiscoverHost, + DiscoverPort as MDDiscoverPort, + DiscoverService as MDDiscoverService, Zone, Host, Port, @@ -27,16 +27,16 @@ export class DiscoveryService { return this.rpcService.call('DiscoveryService.startDiscovery', dsInfo); } - public discoverZone(probeID: string, discoveryZone: DiscoveryZone): void { - this.rpcService.send('DiscoveryService.discoverZone', probeID, discoveryZone); + public discoverZone(probeID: string, discoverZone: MDDiscoverZone): void { + this.rpcService.send('DiscoveryService.discoverZone', probeID, discoverZone); } - public discoverHost(probeID: string, zone: Zone, discoveryHost: DiscoveryHost): void { - this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoveryHost); + public discoverHost(probeID: string, zone: Zone, discoverHost: MDDiscoverHost): void { + this.rpcService.send('DiscoveryService.discoverHost', probeID, zone, discoverHost); } - public discoverPort(probeID: string, host: Host, discoveryPort: DiscoveryPort): void { - this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoveryPort); + public discoverPort(probeID: string, host: Host, discoverPort: MDDiscoverPort): void { + this.rpcService.send('DiscoveryService.discoverPort', probeID, host, discoverPort); } - public discoverService(probeID: string, port: Port, discoveryService: M_DiscoveryService): void { - this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoveryService); + public discoverService(probeID: string, port: Port, discoverService: MDDiscoverService): void { + this.rpcService.send('DiscoveryService.discoverService', probeID, port, discoverService); } } diff --git a/src/packages/discovery/service/target-discovery.service.ts b/src/packages/discovery/service/target-discovery.service.ts index 1f4ec64..17e2aec 100644 --- a/src/packages/discovery/service/target-discovery.service.ts +++ b/src/packages/discovery/service/target-discovery.service.ts @@ -3,10 +3,10 @@ import { Observable } from 'rxjs/Observable'; import { RPCService } from '@loafer/ng-rpc/service'; import { DiscoveryStartInfo, - DiscoveryZone, - DiscoveryHost, - DiscoveryPort, - DiscoveryService as M_DiscoveryService, + DiscoverZone as MDDiscoverZone, + DiscoverHost as MDDiscoverHost, + DiscoverPort as MDDiscoverPort, + DiscoverService as MDDiscoverService, Zone, Host, Port, diff --git a/src/packages/discovery/store/discover/discover.action.ts b/src/packages/discovery/store/discover/discover.action.ts index 733fd8d..34cacae 100644 --- a/src/packages/discovery/store/discover/discover.action.ts +++ b/src/packages/discovery/store/discover/discover.action.ts @@ -5,10 +5,10 @@ import { Host, Port, Service, - DiscoveryZone, - DiscoveryHost, - DiscoveryPort, - DiscoveryService as MDiscoveryService, + DiscoverZone as MDDiscoverZone, + DiscoverHost as MDDiscoverHost, + DiscoverPort as MDDiscoverPort, + DiscoverService as MDiscoverService, } from '../../model'; export enum ActionType { @@ -28,24 +28,24 @@ import { export class DiscoverZone implements Action { readonly type = ActionType.DiscoverZone; - constructor(public payload: {probeID: string, discoveryZone: DiscoveryZone}) {} + constructor(public payload: {probeID: string, discoverZone: MDDiscoverZone}) {} } export class DiscoverHost implements Action { readonly type = ActionType.DiscoverHost; - constructor(public payload: {probeID: string, zone: Zone, discoveryHost: DiscoveryHost}) {} + constructor(public payload: {probeID: string, zone: Zone, discoverHost: MDDiscoverHost}) {} } export class DiscoverPort implements Action { readonly type = ActionType.DiscoverPort; - constructor(public payload: {probeID: string, host: Host, discoveryPort: DiscoveryPort}) {} + constructor(public payload: {probeID: string, host: Host, discoverPort: MDDiscoverPort}) {} } export class DiscoverService implements Action { readonly type = ActionType.DiscoverService; - constructor(public payload: {probeID: string, port: Port, discoveryService: MDiscoveryService}) {} + constructor(public payload: {probeID: string, port: Port, discoverService: MDiscoverService}) {} } export class DiscoveryStart implements Action { diff --git a/src/packages/discovery/store/discover/discover.effect.ts b/src/packages/discovery/store/discover/discover.effect.ts index 0fd5078..92b1448 100644 --- a/src/packages/discovery/store/discover/discover.effect.ts +++ b/src/packages/discovery/store/discover/discover.effect.ts @@ -37,7 +37,7 @@ export class Effects { .ofType(ActionType.DiscoverZone) .map((action: DiscoverZone) => action.payload) .do(payload => { - this.discoveryService.discoverZone(payload.probeID, payload.discoveryZone); + this.discoveryService.discoverZone(payload.probeID, payload.discoverZone); }); @Effect({ dispatch: false }) @@ -45,7 +45,7 @@ export class Effects { .ofType(ActionType.DiscoverHost) .map((action: DiscoverHost) => action.payload) .do(payload => { - this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoveryHost); + this.discoveryService.discoverHost(payload.probeID, payload.zone, payload.discoverHost); }); @Effect({ dispatch: false }) @@ -53,7 +53,7 @@ export class Effects { .ofType(ActionType.DiscoverPort) .map((action: DiscoverPort) => action.payload) .do(payload => { - this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoveryPort); + this.discoveryService.discoverPort(payload.probeID, payload.host, payload.discoverPort); }); @Effect({ dispatch: false }) @@ -61,6 +61,6 @@ export class Effects { .ofType(ActionType.DiscoverService) .map((action: DiscoverService) => action.payload) .do(payload => { - this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoveryService); + this.discoveryService.discoverService(payload.probeID, payload.port, payload.discoverService); }); } diff --git a/src/packages/discovery/store/discover/discover.reducer.ts b/src/packages/discovery/store/discover/discover.reducer.ts index 2adb364..8aac05d 100644 --- a/src/packages/discovery/store/discover/discover.reducer.ts +++ b/src/packages/discovery/store/discover/discover.reducer.ts @@ -70,10 +70,10 @@ export function reducer(state = initialState, action: Actions): State { } if (null === zone.hosts || undefined === zone.hosts) { zone.hosts = new Map(); - zone.hosts.set(host.ip, host); + zone.hosts.set(host.ip4, host); } else { - if (zone.hosts.has(host.ip) === false) { - zone.hosts.set(host.ip, host); + if (zone.hosts.has(host.ip4) === false) { + zone.hosts.set(host.ip4, host); } } @@ -118,7 +118,7 @@ export function reducer(state = initialState, action: Actions): State { zone.hosts = new Map(); } let host: Host = null; - host = zone.hosts.get(port.host.ip); + host = zone.hosts.get(port.host.ip4); if (host === undefined || host === null) { host = port.host; @@ -133,7 +133,7 @@ export function reducer(state = initialState, action: Actions): State { } } - zone.hosts.set(host.ip, host); + zone.hosts.set(host.ip4, host); zones.set(zone.network, zone); const newZones: Map = new Map(); @@ -174,10 +174,10 @@ export function reducer(state = initialState, action: Actions): State { // console.error(`Discovery.DiscoveredPort: Host[${service.port.host.ip}] is not exist`); // } let host: Host = null; - host = zone.hosts.get(service.port.host.ip); + host = zone.hosts.get(service.port.host.ip4); if (host === undefined || host === null) { - zone.hosts.set(service.port.host.ip, service.port.host); + zone.hosts.set(service.port.host.ip4, service.port.host); host = service.port.host; } @@ -199,7 +199,7 @@ export function reducer(state = initialState, action: Actions): State { port.services.set(service.serviceName, service); host.ports.set(service.port.portNumber, port); - zone.hosts.set(host.ip, host); + zone.hosts.set(host.ip4, host); zones.set(zone.network, zone); const newZones: Map = new Map();