From 160d40b4554b0fc9cf28b9305c503640071b76a8 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 4 Sep 2018 01:12:10 +0900 Subject: [PATCH] ing --- .../model/config/credential/Credential.ts | 2 + .../model/config/credential/SNMPCredential.ts | 14 +++++ .../model/config/credential/UnixCredential.ts | 12 ++++ .../config/credential/WindowsCredential.ts | 7 +++ @overflow/model/discovery/DiscoverHost.ts | 16 +++++ @overflow/model/discovery/DiscoverPort.ts | 15 +++++ @overflow/model/discovery/DiscoverService.ts | 7 +++ @overflow/model/discovery/DiscoverZone.ts | 6 ++ @overflow/model/discovery/DiscoveryConfig.ts | 5 ++ @overflow/model/discovery/Host.ts | 16 +++++ @overflow/model/discovery/Port.ts | 14 +++++ @overflow/model/discovery/Service.ts | 13 ++++ @overflow/model/discovery/Zone.ts | 13 ++++ @overflow/model/discovery/index.ts | 9 +++ @overflow/model/meta/MetaCredentialType.ts | 29 +++++++++ package.json | 2 +- src/app/pages/home/home-page.component.html | 2 +- src/app/pages/home/home-page.component.ts | 63 ++++++++++++++++++- src/commons/service/probe.service.ts | 2 +- yarn.lock | 6 +- 20 files changed, 246 insertions(+), 7 deletions(-) create mode 100644 @overflow/model/config/credential/Credential.ts create mode 100644 @overflow/model/config/credential/SNMPCredential.ts create mode 100644 @overflow/model/config/credential/UnixCredential.ts create mode 100644 @overflow/model/config/credential/WindowsCredential.ts create mode 100644 @overflow/model/discovery/DiscoverHost.ts create mode 100644 @overflow/model/discovery/DiscoverPort.ts create mode 100644 @overflow/model/discovery/DiscoverService.ts create mode 100644 @overflow/model/discovery/DiscoverZone.ts create mode 100644 @overflow/model/discovery/DiscoveryConfig.ts create mode 100644 @overflow/model/discovery/Host.ts create mode 100644 @overflow/model/discovery/Port.ts create mode 100644 @overflow/model/discovery/Service.ts create mode 100644 @overflow/model/discovery/Zone.ts create mode 100644 @overflow/model/discovery/index.ts create mode 100644 @overflow/model/meta/MetaCredentialType.ts diff --git a/@overflow/model/config/credential/Credential.ts b/@overflow/model/config/credential/Credential.ts new file mode 100644 index 0000000..42b0035 --- /dev/null +++ b/@overflow/model/config/credential/Credential.ts @@ -0,0 +1,2 @@ +export interface Credential { +} diff --git a/@overflow/model/config/credential/SNMPCredential.ts b/@overflow/model/config/credential/SNMPCredential.ts new file mode 100644 index 0000000..e18b0a8 --- /dev/null +++ b/@overflow/model/config/credential/SNMPCredential.ts @@ -0,0 +1,14 @@ +import { Credential } from './Credential'; + +export interface SNMPCredential extends Credential { + version?: string; + vommunity?: string; + authenticationType?: string; + user?: string; + password?: string; + encryptionType?: string; + dataEncryptionKey?: string; + contextName?: string; + port?: number; + timeout?: number; +} diff --git a/@overflow/model/config/credential/UnixCredential.ts b/@overflow/model/config/credential/UnixCredential.ts new file mode 100644 index 0000000..de4af44 --- /dev/null +++ b/@overflow/model/config/credential/UnixCredential.ts @@ -0,0 +1,12 @@ +import { Credential } from './Credential'; + +export interface UnixCredential extends Credential { + user?: string; + loginType?: string; + password?: string; + privateKey?: string; + sshPort?: number; + sshRightsElevationType?: string; + targetUser?: string; + targetUserPassword?: string; +} diff --git a/@overflow/model/config/credential/WindowsCredential.ts b/@overflow/model/config/credential/WindowsCredential.ts new file mode 100644 index 0000000..d775025 --- /dev/null +++ b/@overflow/model/config/credential/WindowsCredential.ts @@ -0,0 +1,7 @@ +import { Credential } from './Credential'; + +export interface SNMPCredential extends Credential { + domainName?: string; + user?: string; + password?: string; +} diff --git a/@overflow/model/discovery/DiscoverHost.ts b/@overflow/model/discovery/DiscoverHost.ts new file mode 100644 index 0000000..bc03385 --- /dev/null +++ b/@overflow/model/discovery/DiscoverHost.ts @@ -0,0 +1,16 @@ +import { DiscoverPort } from './DiscoverPort'; +import { MetaIPType } from '../meta'; +import { DiscoveryConfig } from './DiscoveryConfig'; + +export interface DiscoverHost { + discoveryConfig?: DiscoveryConfig; + + metaIPType?: MetaIPType; + + firstScanRange?: string; + lastScanRange?: string; + excludeHosts?: string[]; + includeHosts?: string[]; + + discoverPort?: DiscoverPort; +} diff --git a/@overflow/model/discovery/DiscoverPort.ts b/@overflow/model/discovery/DiscoverPort.ts new file mode 100644 index 0000000..722607b --- /dev/null +++ b/@overflow/model/discovery/DiscoverPort.ts @@ -0,0 +1,15 @@ +import { DiscoverService } from './DiscoverService'; +import { DiscoveryConfig } from './DiscoveryConfig'; + +export interface DiscoverPort { + discoveryConfig?: DiscoveryConfig; + + firstScanRange?: number; + lastScanRange?: number; + excludePorts?: number[]; + + includeTCP?: boolean; + includeUDP?: boolean; + + discoverService?: DiscoverService; +} diff --git a/@overflow/model/discovery/DiscoverService.ts b/@overflow/model/discovery/DiscoverService.ts new file mode 100644 index 0000000..3120bee --- /dev/null +++ b/@overflow/model/discovery/DiscoverService.ts @@ -0,0 +1,7 @@ +import { DiscoveryConfig } from './DiscoveryConfig'; + +export interface DiscoverService { + discoveryConfig?: DiscoveryConfig; + + includeServices?: string[]; +} diff --git a/@overflow/model/discovery/DiscoverZone.ts b/@overflow/model/discovery/DiscoverZone.ts new file mode 100644 index 0000000..df116fc --- /dev/null +++ b/@overflow/model/discovery/DiscoverZone.ts @@ -0,0 +1,6 @@ +import { DiscoverHost } from './DiscoverHost'; + +export interface DiscoverZone { + excludePatterns?: string[]; + discoverHost?: DiscoverHost; +} diff --git a/@overflow/model/discovery/DiscoveryConfig.ts b/@overflow/model/discovery/DiscoveryConfig.ts new file mode 100644 index 0000000..d32f3aa --- /dev/null +++ b/@overflow/model/discovery/DiscoveryConfig.ts @@ -0,0 +1,5 @@ +import { DiscoverHost } from './DiscoverHost'; + +export interface DiscoveryConfig { + credentials?: Map; +} diff --git a/@overflow/model/discovery/Host.ts b/@overflow/model/discovery/Host.ts new file mode 100644 index 0000000..d871fc4 --- /dev/null +++ b/@overflow/model/discovery/Host.ts @@ -0,0 +1,16 @@ +import { Zone } from './Zone'; +import { Port } from './Port'; +import { MetaIPType } from '../meta'; + +export interface Host { + metaIPType?: MetaIPType; + name?: string; + address?: string; + mac?: string; + meta?: Map; + + zone?: Zone; + portList?: Port[]; + + discoveredDate?: Date; +} diff --git a/@overflow/model/discovery/Port.ts b/@overflow/model/discovery/Port.ts new file mode 100644 index 0000000..3587a89 --- /dev/null +++ b/@overflow/model/discovery/Port.ts @@ -0,0 +1,14 @@ +import { Host } from './Host'; +import { Service } from './Service'; +import { MetaPortType } from '../meta'; + +export interface Port { + metaPortType?: MetaPortType; + portNumber?: number; + meta?: Map; + + discoveredDate?: Date; + + host?: Host; + serviceList?: Service[]; +} diff --git a/@overflow/model/discovery/Service.ts b/@overflow/model/discovery/Service.ts new file mode 100644 index 0000000..5a66e76 --- /dev/null +++ b/@overflow/model/discovery/Service.ts @@ -0,0 +1,13 @@ +import { Port } from './Port'; +import { MetaCryptoType } from '../meta'; + +export interface Service { + metaCryptoType?: MetaCryptoType; + key?: string; + description?: string; + meta?: Map; + + port?: Port; + + discoveredDate?: Date; +} diff --git a/@overflow/model/discovery/Zone.ts b/@overflow/model/discovery/Zone.ts new file mode 100644 index 0000000..a079ca1 --- /dev/null +++ b/@overflow/model/discovery/Zone.ts @@ -0,0 +1,13 @@ +import { Host } from './Host'; +import { MetaIPType } from '../meta'; + +export interface Zone { + network?: string; + iface?: string; + metaIPType?: MetaIPType; + address?: string; + mac?: string; + meta?: Map; + + discoveredDate?: Date; +} diff --git a/@overflow/model/discovery/index.ts b/@overflow/model/discovery/index.ts new file mode 100644 index 0000000..8166441 --- /dev/null +++ b/@overflow/model/discovery/index.ts @@ -0,0 +1,9 @@ +export * from './DiscoverHost'; +export * from './DiscoverPort'; +export * from './DiscoverService'; +export * from './DiscoverZone'; + +export * from './Host'; +export * from './Port'; +export * from './Service'; +export * from './Zone'; diff --git a/@overflow/model/meta/MetaCredentialType.ts b/@overflow/model/meta/MetaCredentialType.ts new file mode 100644 index 0000000..2018174 --- /dev/null +++ b/@overflow/model/meta/MetaCredentialType.ts @@ -0,0 +1,29 @@ +export interface MetaCredentialType { + id?: number; + name?: string; + key?: string; + createDate?: Date; +} + +export enum MetaCredentialTypeEnum { + NONE = 'NONE', + Windows = 'WINDOWS', + Linux = 'LINUX', + Solaris = 'SOLARIS', + MacOS = 'MACOS', + VMWare = 'VMWARE', + XenServer = 'XENSERVER', + SNMP = 'SNMP', + Database = 'DATABASE', + AmazoneCloudWatch = 'AMAZON_CLOUDWATCH', +} + +export const toMetaCredentialTypeEnum = (v: MetaCredentialType): MetaCredentialTypeEnum => { + return MetaCredentialTypeEnum[v.key]; +}; + +export const toMetaCredentialType = (v: MetaCredentialTypeEnum): MetaCredentialType => { + return { + key: v, + }; +}; diff --git a/package.json b/package.json index 5f4f9e6..31d7f39 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@ngrx/schematics": "^6.1.0", "@ngrx/store": "^6.1.0", "@ngrx/store-devtools": "^6.1.0", - "@overflow/rpc-js": "0.0.1", + "@overflow/rpc-js": "0.0.2", "@types/fs-extra": "^5.0.4", "@types/jasmine": "~2.8.6", "@types/jasminewd2": "~2.0.3", diff --git a/src/app/pages/home/home-page.component.html b/src/app/pages/home/home-page.component.html index 0f4fd3a..ccb75df 100644 --- a/src/app/pages/home/home-page.component.html +++ b/src/app/pages/home/home-page.component.html @@ -1,5 +1,5 @@
-
+
diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index f2b4949..a78e122 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -1,5 +1,14 @@ import { Component, OnInit } from '@angular/core'; +import { Observable, Subscription, of } from 'rxjs'; +import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators'; + +import { ProbeService } from '../../../commons/service/probe.service'; + +import { Interface } from '@overflow/model/net/nic'; +import { Zone, DiscoverHost } from '@overflow/model/discovery'; +import { toMetaIPType, MetaIPTypeEnum } from '@overflow/model/meta'; +import { Address } from '../../../commons/component/nic-dropdown.component'; @Component({ @@ -12,8 +21,11 @@ export class HomePageComponent implements OnInit { blockedPanel = false; blockedDocument = false; + addresses: Address[]; - constructor() { } + constructor( + private probeService: ProbeService, + ) { } ngOnInit() { } @@ -25,4 +37,53 @@ export class HomePageComponent implements OnInit { this.blockedDocument = false; }, 3000); } + + discoverHost() { + 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', 'testRequesterID', zone, discoverHost); + + // this.probeService.call('MachineService.Interfaces').pipe( + // map((ifaces: Interface[]) => { + // console.log(ifaces); + // this.addresses = []; + // ifaces.forEach(iface => { + // iface.addresses.forEach(address => { + // this.addresses.push({ + // label: address.address, + // value: address.address, + // }); + // }); + // }); + // }), + // catchError(error => { + // console.log(error); + // return of(); + // }), + // take(1), + // ).subscribe(); + } + } diff --git a/src/commons/service/probe.service.ts b/src/commons/service/probe.service.ts index a26cf1f..eda7eac 100644 --- a/src/commons/service/probe.service.ts +++ b/src/commons/service/probe.service.ts @@ -9,7 +9,7 @@ import { import { Subscription } from 'rxjs'; const config: WebSocketClientRWCConfig = { - url: 'ws://localhost:60000/' + url: 'ws://localhost:60000/scanner' }; const rwc = new WebSocketClientRWC(config); const codec = new JSONClientCodec(); diff --git a/yarn.lock b/yarn.lock index 9cdd9e0..7d514f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -224,9 +224,9 @@ tree-kill "^1.0.0" webpack-sources "^1.1.0" -"@overflow/rpc-js@0.0.1": - version "0.0.1" - resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.1.tgz#471602a8a49f19c0ba888ad24717e9659493ed52" +"@overflow/rpc-js@0.0.2": + version "0.0.2" + resolved "https://nexus.loafle.net/repository/npm-all/@overflow/rpc-js/-/rpc-js-0.0.2.tgz#16a628f988cb2994d5b02d0c871340d9df6819e2" "@schematics/angular@0.7.3": version "0.7.3"